From db83e39a7f3c053a65667c5c31afd8b26b5ebfa7 Mon Sep 17 00:00:00 2001 From: mpostma Date: Tue, 11 Jan 2022 18:01:25 +0100 Subject: [PATCH] bug(http): fix task duration --- meilisearch-http/src/task.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/task.rs b/meilisearch-http/src/task.rs index 1eba76ca8..7fa53c8dd 100644 --- a/meilisearch-http/src/task.rs +++ b/meilisearch-http/src/task.rs @@ -224,13 +224,13 @@ impl From 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(),