Add optional run end time override

This commit is contained in:
Joscha 2023-08-14 14:15:38 +02:00
parent 6b8ae19ba5
commit 01124d719b
3 changed files with 12 additions and 1 deletions

View file

@ -35,7 +35,7 @@ async fn save_work(finished: FinishedRun, db: &SqlitePool) -> somehow::Result<()
let mut tx = db.begin().await?; let mut tx = db.begin().await?;
let conn = tx.acquire().await?; let conn = tx.acquire().await?;
let end = OffsetDateTime::now_utc(); let end = finished.end.unwrap_or_else(OffsetDateTime::now_utc);
let bench_method = match finished.run.bench_method { let bench_method = match finished.run.bench_method {
BenchMethod::Internal => "internal".to_string(), BenchMethod::Internal => "internal".to_string(),
BenchMethod::Repo { hash } => format!("bench repo, hash {hash}"), BenchMethod::Repo { hash } => format!("bench repo, hash {hash}"),

View file

@ -65,10 +65,20 @@ pub struct UnfinishedRun {
pub struct FinishedRun { pub struct FinishedRun {
#[serde(flatten)] #[serde(flatten)]
pub run: Run, pub run: Run,
/// Override the server's end time.
///
/// Should not be used in normal operation, but can be used when importing
/// completed runs from other sources.
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<OffsetDateTime>,
#[serde(default)] #[serde(default)]
pub exit_code: i32, pub exit_code: i32,
#[serde(default)] #[serde(default)]
pub output: Vec<(Source, String)>, pub output: Vec<(Source, String)>,
#[serde(default)] #[serde(default)]
pub measurements: HashMap<String, Measurement>, pub measurements: HashMap<String, Measurement>,
} }

View file

@ -97,6 +97,7 @@ impl RunInProgress {
Some(FinishedRun { Some(FinishedRun {
run: self.run.clone(), run: self.run.clone(),
end: None,
exit_code: finished.exit_code, exit_code: finished.exit_code,
output, output,
measurements: finished.measurements, measurements: finished.measurements,