mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-26 06:44:27 +01:00
fixup! Extract the dates out of the dumpv4.
This commit is contained in:
parent
ab3056cc66
commit
953b2ec438
@ -24,6 +24,7 @@ pub type Unchecked = settings::Unchecked;
|
|||||||
|
|
||||||
pub type Task = tasks::Task;
|
pub type Task = tasks::Task;
|
||||||
pub type TaskEvent = tasks::TaskEvent;
|
pub type TaskEvent = tasks::TaskEvent;
|
||||||
|
pub type TaskContent = tasks::TaskContent;
|
||||||
pub type Key = keys::Key;
|
pub type Key = keys::Key;
|
||||||
|
|
||||||
// everything related to the settings
|
// everything related to the settings
|
||||||
@ -153,27 +154,41 @@ impl V4IndexReader {
|
|||||||
let meta = File::open(path.join("meta.json"))?;
|
let meta = File::open(path.join("meta.json"))?;
|
||||||
let meta: DumpMeta = serde_json::from_reader(meta)?;
|
let meta: DumpMeta = serde_json::from_reader(meta)?;
|
||||||
|
|
||||||
let mut index_tasks: Vec<Task> = vec![];
|
let mut created_at = None;
|
||||||
|
let mut updated_at = None;
|
||||||
|
|
||||||
for line in tasks.lines() {
|
for line in tasks.lines() {
|
||||||
let task: Task = serde_json::from_str(&line?)?;
|
let task: Task = serde_json::from_str(&line?)?;
|
||||||
|
|
||||||
if task.index_uid.to_string() == name {
|
if task.index_uid.to_string() == name {
|
||||||
index_tasks.push(task)
|
if updated_at.is_none() {
|
||||||
|
updated_at = match task.events.last() {
|
||||||
|
Some(TaskEvent::Created(ts)) => Some(*ts),
|
||||||
|
_ => None,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if created_at.is_some() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let metadata = IndexMetadata {
|
let metadata = IndexMetadata {
|
||||||
uid: name,
|
uid: name,
|
||||||
primary_key: meta.primary_key,
|
primary_key: meta.primary_key,
|
||||||
created_at: match index_tasks.first().unwrap().events.first() {
|
created_at: created_at.unwrap_or(OffsetDateTime::now_utc()),
|
||||||
Some(TaskEvent::Created(ts)) => *ts,
|
updated_at: updated_at.unwrap_or(OffsetDateTime::now_utc()),
|
||||||
_ => OffsetDateTime::now_utc(),
|
|
||||||
},
|
|
||||||
updated_at: match index_tasks.last().unwrap().events.last() {
|
|
||||||
Some(TaskEvent::Created(ts)) => *ts,
|
|
||||||
_ => OffsetDateTime::now_utc(),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let ret = V4IndexReader {
|
let ret = V4IndexReader {
|
||||||
|
Loading…
Reference in New Issue
Block a user