use crate::standards_review_request::ROUTE;
use crate::standards_review_input::CAP_LINES;
use crate::standards_review_text::on_one_line;
pub const SHORT_SHA_LENGTH: usize = 12;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ReviewEntry {
pub date: String,
pub sha: String,
pub subject: String,
pub code_files: usize,
pub diff_lines: usize,
pub truncated: bool,
pub input_units: usize,
pub seconds: String,
pub top: String,
pub outcome: String,
}
fn short(sha: &str) -> String {
return sha.chars().take(SHORT_SHA_LENGTH).collect();
}
pub fn render_skipped(sha: &str, subject: &str) -> String {
return format!("- Skipped:\n {} (no code files):\n `{}`\n", short(sha), on_one_line(subject));
}
pub fn render_review(entry: &ReviewEntry) -> String {
let capped: String = if entry.truncated { format!(", capped at {CAP_LINES}") } else { String::new() };
let judged: String = match entry.top.as_str() {
"partial" => String::from(" partial (cost gestured as unverified,\n not named)"),
"yes" | "no" => format!(" {}", entry.top),
_ => String::from(" unjudged"),
};
return format!(
"- Date:\n {date}\n Subject:\n {sha} `{subject}`\n Input size:\n `{files} code files, {lines} diff lines{capped}, luna input {units} chars`\n Reviewer route:\n `{ROUTE}`\n Wall-clock cost:\n {seconds} s\n Named superlinear cost:\n{judged}\n Findings kept:\n `````text\n {outcome}\n `````\n\n",
date = entry.date,
sha = short(entry.sha.as_str()),
subject = on_one_line(entry.subject.as_str()),
files = entry.code_files,
lines = entry.diff_lines,
units = entry.input_units,
seconds = entry.seconds,
outcome = on_one_line(entry.outcome.as_str()),
);
}
#[cfg(test)]
#[path = "standards_review_entry_tests.rs"]
mod tests;