bug(http): fix task duration

This commit is contained in:
mpostma 2022-01-11 18:01:25 +01:00
parent 1818026a84
commit db83e39a7f

View File

@ -224,13 +224,13 @@ impl From<Task> for TaskView {
_ => unreachable!("A task must always have a creation event."),
};
let duration = finished_at.map(|ts| (ts - enqueued_at));
let started_at = events.iter().find_map(|e| match e {
TaskEvent::Processing(ts) => Some(*ts),
_ => None,
});
let duration = finished_at.zip(started_at).map(|(tf, ts)| (tf - ts));
Self {
uid: id,
index_uid: index_uid.into_inner(),