From 1be4619b91bab19920bd2ed3b25fe5ed0b933d41 Mon Sep 17 00:00:00 2001 From: funilrys Date: Sat, 3 Dec 2022 18:59:08 +0100 Subject: [PATCH] Add reader.v5.tasks.Task.created_at. There was no way to "quickly" get the creation date. --- dump/src/reader/v5/tasks.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dump/src/reader/v5/tasks.rs b/dump/src/reader/v5/tasks.rs index 61397dd24..528a870fc 100644 --- a/dump/src/reader/v5/tasks.rs +++ b/dump/src/reader/v5/tasks.rs @@ -147,6 +147,38 @@ impl Task { _ => None, } } + + pub fn created_at(&self) -> Option { + match &self.content { + TaskContent::IndexCreation { index_uid: _, primary_key: _ } => { + match self.events.first() { + Some(TaskEvent::Created(ts)) => Some(*ts), + _ => None, + } + } + TaskContent::DocumentAddition { + index_uid: _, + content_uuid: _, + merge_strategy: _, + primary_key: _, + documents_count: _, + allow_index_creation: _, + } => match self.events.first() { + Some(TaskEvent::Created(ts)) => Some(*ts), + _ => None, + }, + TaskContent::SettingsUpdate { + index_uid: _, + settings: _, + is_deletion: _, + allow_index_creation: _, + } => match self.events.first() { + Some(TaskEvent::Created(ts)) => Some(*ts), + _ => None, + }, + _ => None, + } + } } impl IndexUid {