mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
start moving a lot of task types to meilisearch_types
This commit is contained in:
parent
974b40ba04
commit
e6c033bd6b
18 changed files with 416 additions and 347 deletions
|
@ -52,14 +52,12 @@ pub(crate) mod test {
|
|||
};
|
||||
|
||||
use big_s::S;
|
||||
use index_scheduler::{
|
||||
task::{Details, DetailsView},
|
||||
Kind, Status, TaskView,
|
||||
};
|
||||
use index_scheduler::task::Details;
|
||||
use maplit::btreeset;
|
||||
use meilisearch_auth::{Action, Key};
|
||||
use meilisearch_types::milli::{self, update::Setting};
|
||||
use meilisearch_types::settings::{Checked, Settings};
|
||||
use meilisearch_types::tasks::{DetailsView, Kind, Status, TaskView};
|
||||
use meilisearch_types::{index_uid::IndexUid, star_or::StarOr};
|
||||
use serde_json::{json, Map, Value};
|
||||
use time::{macros::datetime, Duration};
|
||||
|
|
|
@ -102,9 +102,7 @@ impl CompatV5ToV6 {
|
|||
},
|
||||
v5::tasks::TaskContent::Dump { .. } => v6::Kind::DumpExport,
|
||||
},
|
||||
details: todo!(),
|
||||
/*
|
||||
task_view.details.map(|details| match details {
|
||||
details: task_view.details.map(|details| match details {
|
||||
v5::Details::DocumentAddition {
|
||||
received_documents,
|
||||
indexed_documents,
|
||||
|
@ -130,9 +128,7 @@ impl CompatV5ToV6 {
|
|||
}
|
||||
v5::Details::Dump { dump_uid } => v6::Details::Dump { dump_uid },
|
||||
}),
|
||||
*/
|
||||
error: task_view.error.map(|e| e.into()),
|
||||
duration: task_view.duration,
|
||||
enqueued_at: task_view.enqueued_at,
|
||||
started_at: task_view.started_at,
|
||||
finished_at: task_view.finished_at,
|
||||
|
|
|
@ -21,14 +21,14 @@ pub type Settings<T> = meilisearch_types::settings::Settings<T>;
|
|||
pub type Checked = meilisearch_types::settings::Checked;
|
||||
pub type Unchecked = meilisearch_types::settings::Unchecked;
|
||||
|
||||
pub type Task = index_scheduler::TaskView;
|
||||
pub type Task = meilisearch_types::tasks::TaskDump;
|
||||
pub type Key = meilisearch_auth::Key;
|
||||
|
||||
// ===== Other types to clarify the code of the compat module
|
||||
// everything related to the tasks
|
||||
pub type Status = index_scheduler::Status;
|
||||
pub type Kind = index_scheduler::Kind;
|
||||
pub type Details = index_scheduler::Details;
|
||||
pub type Status = meilisearch_types::tasks::Status;
|
||||
pub type Kind = meilisearch_types::tasks::Kind;
|
||||
pub type Details = meilisearch_types::tasks::Details;
|
||||
|
||||
// everything related to the settings
|
||||
pub type Setting<T> = meilisearch_types::milli::update::Setting<T>;
|
||||
|
@ -109,11 +109,8 @@ impl V6Reader {
|
|||
&mut self,
|
||||
) -> Box<dyn Iterator<Item = Result<(Task, Option<Box<super::UpdateFile>>)>> + '_> {
|
||||
Box::new((&mut self.tasks).lines().map(|line| -> Result<_> {
|
||||
let mut task: index_scheduler::TaskView = todo!(); // serde_json::from_str(&line?)?;
|
||||
// TODO: this can be removed once we can `Deserialize` the duration from the `TaskView`.
|
||||
if let Some((started_at, finished_at)) = task.started_at.zip(task.finished_at) {
|
||||
task.duration = Some(finished_at - started_at);
|
||||
}
|
||||
let task: Task = serde_json::from_str(&line?)?;
|
||||
|
||||
let update_file_path = self
|
||||
.dump
|
||||
.path()
|
||||
|
|
|
@ -5,9 +5,9 @@ use std::{
|
|||
};
|
||||
|
||||
use flate2::{write::GzEncoder, Compression};
|
||||
use index_scheduler::TaskView;
|
||||
use meilisearch_auth::Key;
|
||||
use meilisearch_types::settings::{Checked, Settings};
|
||||
use meilisearch_types::tasks::TaskDump;
|
||||
use serde_json::{Map, Value};
|
||||
use tempfile::TempDir;
|
||||
use time::OffsetDateTime;
|
||||
|
@ -105,17 +105,12 @@ impl TaskWriter {
|
|||
|
||||
/// Pushes tasks in the dump.
|
||||
/// If the tasks has an associated `update_file` it'll use the `task_id` as its name.
|
||||
pub fn push_task(&mut self, task: &TaskView) -> Result<UpdateFile> {
|
||||
// TODO: this could be removed the day we implements `Deserialize` on the Duration.
|
||||
let mut task = task.clone();
|
||||
task.duration = None;
|
||||
|
||||
self.queue.write_all(&serde_json::to_vec(&task)?)?;
|
||||
pub fn push_task(&mut self, task: &TaskDump) -> Result<UpdateFile> {
|
||||
self.queue.write_all(&serde_json::to_vec(task)?)?;
|
||||
self.queue.write_all(b"\n")?;
|
||||
|
||||
Ok(UpdateFile::new(
|
||||
self.update_files
|
||||
.join(format!("{}.jsonl", task.uid.to_string())),
|
||||
self.update_files.join(format!("{}.jsonl", task.uid)),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue