mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
fixup! Extract the dates out of the dumpv4.
This commit is contained in:
parent
953b2ec438
commit
06e7db7a1f
@ -13,7 +13,7 @@ pub mod meta;
|
||||
pub mod settings;
|
||||
pub mod tasks;
|
||||
|
||||
use self::meta::{DumpMeta, IndexUuid};
|
||||
use self::meta::{DumpMeta, IndexMeta, IndexUuid};
|
||||
use super::compat::v4_to_v5::CompatV4ToV5;
|
||||
use crate::{Error, IndexMetadata, Result, Version};
|
||||
|
||||
@ -23,8 +23,6 @@ pub type Checked = settings::Checked;
|
||||
pub type Unchecked = settings::Unchecked;
|
||||
|
||||
pub type Task = tasks::Task;
|
||||
pub type TaskEvent = tasks::TaskEvent;
|
||||
pub type TaskContent = tasks::TaskContent;
|
||||
pub type Key = keys::Key;
|
||||
|
||||
// everything related to the settings
|
||||
@ -102,6 +100,7 @@ impl V4Reader {
|
||||
V4IndexReader::new(
|
||||
index.uid.clone(),
|
||||
&self.dump.path().join("indexes").join(index.index_meta.uuid.to_string()),
|
||||
&index.index_meta,
|
||||
BufReader::new(self.tasks.get_ref().try_clone().unwrap()),
|
||||
)
|
||||
}))
|
||||
@ -150,7 +149,12 @@ pub struct V4IndexReader {
|
||||
}
|
||||
|
||||
impl V4IndexReader {
|
||||
pub fn new(name: String, path: &Path, tasks: BufReader<File>) -> Result<Self> {
|
||||
pub fn new(
|
||||
name: String,
|
||||
path: &Path,
|
||||
index_metadata: &IndexMeta,
|
||||
tasks: BufReader<File>,
|
||||
) -> Result<Self> {
|
||||
let meta = File::open(path.join("meta.json"))?;
|
||||
let meta: DumpMeta = serde_json::from_reader(meta)?;
|
||||
|
||||
@ -162,23 +166,14 @@ impl V4IndexReader {
|
||||
|
||||
if task.index_uid.to_string() == name {
|
||||
if updated_at.is_none() {
|
||||
updated_at = match task.events.last() {
|
||||
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||
_ => None,
|
||||
};
|
||||
updated_at = task.updated_at()
|
||||
}
|
||||
|
||||
if created_at.is_none() {
|
||||
created_at = match task.content {
|
||||
TaskContent::IndexCreation { primary_key } => match task.events.first() {
|
||||
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
created_at = task.created_at()
|
||||
}
|
||||
|
||||
if created_at.is_some() {
|
||||
if task.id as usize == index_metadata.creation_task_id {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -104,6 +104,33 @@ impl Task {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn updated_at(&self) -> Option<OffsetDateTime> {
|
||||
match self.events.last() {
|
||||
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn created_at(&self) -> Option<OffsetDateTime> {
|
||||
match &self.content {
|
||||
TaskContent::IndexCreation { primary_key: _ } => match self.events.first() {
|
||||
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||
_ => None,
|
||||
},
|
||||
TaskContent::DocumentAddition {
|
||||
content_uuid: _,
|
||||
merge_strategy: _,
|
||||
primary_key: _,
|
||||
documents_count: _,
|
||||
allow_index_creation: _,
|
||||
} => match self.events.first() {
|
||||
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the content_uuid of the `Task` if there is one.
|
||||
pub fn get_content_uuid(&self) -> Option<Uuid> {
|
||||
match self {
|
||||
|
Loading…
Reference in New Issue
Block a user