From 9a39c4e40d549b2aae16339203f50097a2466e96 Mon Sep 17 00:00:00 2001 From: amab8901 Date: Thu, 22 Dec 2022 11:46:17 +0100 Subject: [PATCH] Get date from IndexMetaData --- index-scheduler/src/index_mapper.rs | 5 +++-- index-scheduler/src/lib.rs | 5 ++--- meilisearch/src/lib.rs | 7 +------ 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/index-scheduler/src/index_mapper.rs b/index-scheduler/src/index_mapper.rs index de9e47df3..02b53749f 100644 --- a/index-scheduler/src/index_mapper.rs +++ b/index-scheduler/src/index_mapper.rs @@ -9,6 +9,7 @@ use meilisearch_types::heed::types::Str; use meilisearch_types::heed::{Database, Env, EnvOpenOptions, RoTxn, RwTxn}; use meilisearch_types::milli::update::IndexerConfig; use meilisearch_types::milli::Index; +use time::OffsetDateTime; use uuid::Uuid; use self::IndexStatus::{Available, BeingDeleted}; @@ -69,7 +70,7 @@ impl IndexMapper { fn create_or_open_index( &self, path: &Path, - date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, + date: Option<(OffsetDateTime, OffsetDateTime)>, ) -> Result { let mut options = EnvOpenOptions::new(); options.map_size(clamp_to_page_size(self.index_size)); @@ -87,7 +88,7 @@ impl IndexMapper { &self, mut wtxn: RwTxn, name: &str, - date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, + date: Option<(OffsetDateTime, OffsetDateTime)>, ) -> Result { match self.index(&wtxn, name) { Ok(index) => { diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 205fc4a50..c9d5f2ec9 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -693,7 +693,7 @@ impl IndexScheduler { let mut task = Task { uid: self.next_task_id(&wtxn)?, - enqueued_at: time::OffsetDateTime::now_utc(), + enqueued_at: OffsetDateTime::now_utc(), started_at: None, finished_at: None, error: None, @@ -868,11 +868,10 @@ impl IndexScheduler { pub fn create_raw_index( &self, name: &str, - date: Option<(time::OffsetDateTime, time::OffsetDateTime)>, + date: Option<(OffsetDateTime, OffsetDateTime)>, ) -> Result { let wtxn = self.env.write_txn()?; let index = self.index_mapper.create_index(wtxn, name, date)?; - Ok(index) } diff --git a/meilisearch/src/lib.rs b/meilisearch/src/lib.rs index 83631e5b2..3797a3a44 100644 --- a/meilisearch/src/lib.rs +++ b/meilisearch/src/lib.rs @@ -289,13 +289,8 @@ fn import_dump( let mut index_reader = index_reader?; let metadata = index_reader.metadata(); log::info!("Importing index `{}`.", metadata.uid); - let date; - if let Some(dump_reader_date) = dump_reader.date() { - date = Some((dump_reader_date, dump_reader_date)); - } else { - date = Some((time::OffsetDateTime::now_utc(), time::OffsetDateTime::now_utc())); - } + let date = Some((metadata.created_at, metadata.updated_at)); let index = index_scheduler.create_raw_index(&metadata.uid, date)?; let mut wtxn = index.write_txn()?;