mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
rename a few things for consistency
This commit is contained in:
parent
a8128678a4
commit
2f47443458
@ -2,6 +2,7 @@
|
|||||||
// pub mod v3;
|
// pub mod v3;
|
||||||
// pub mod v4;
|
// pub mod v4;
|
||||||
|
|
||||||
|
// pub mod v4_to_v5;
|
||||||
pub mod v5_to_v6;
|
pub mod v5_to_v6;
|
||||||
|
|
||||||
pub struct Compat<From: ?Sized> {
|
pub struct Compat<From: ?Sized> {
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::fs::File;
|
|
||||||
|
|
||||||
use crate::reader::{v5, v6, DumpReader, IndexReader};
|
use crate::reader::{v5, v6, DumpReader, IndexReader};
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
@ -44,52 +42,52 @@ impl DumpReader for CompatV5ToV6 {
|
|||||||
) -> Box<dyn Iterator<Item = Result<(v6::Task, Option<v6::UpdateFile>)>> + '_> {
|
) -> Box<dyn Iterator<Item = Result<(v6::Task, Option<v6::UpdateFile>)>> + '_> {
|
||||||
Box::new(self.from.tasks().map(|task| {
|
Box::new(self.from.tasks().map(|task| {
|
||||||
task.map(|(task, content_file)| {
|
task.map(|(task, content_file)| {
|
||||||
let task_view: v5::TaskView = task.into();
|
let task_view: v5::tasks::TaskView = task.into();
|
||||||
|
|
||||||
let task = v6::Task {
|
let task = v6::Task {
|
||||||
uid: task_view.uid,
|
uid: task_view.uid,
|
||||||
index_uid: task_view.index_uid,
|
index_uid: task_view.index_uid,
|
||||||
status: match task_view.status {
|
status: match task_view.status {
|
||||||
v5::TaskStatus::Enqueued => v6::Status::Enqueued,
|
v5::Status::Enqueued => v6::Status::Enqueued,
|
||||||
v5::TaskStatus::Processing => v6::Status::Enqueued,
|
v5::Status::Processing => v6::Status::Enqueued,
|
||||||
v5::TaskStatus::Succeeded => v6::Status::Succeeded,
|
v5::Status::Succeeded => v6::Status::Succeeded,
|
||||||
v5::TaskStatus::Failed => v6::Status::Failed,
|
v5::Status::Failed => v6::Status::Failed,
|
||||||
},
|
},
|
||||||
kind: match task_view.task_type {
|
kind: match task_view.task_type {
|
||||||
v5::TaskType::IndexCreation => v6::Kind::IndexCreation,
|
v5::Kind::IndexCreation => v6::Kind::IndexCreation,
|
||||||
v5::TaskType::IndexUpdate => v6::Kind::IndexUpdate,
|
v5::Kind::IndexUpdate => v6::Kind::IndexUpdate,
|
||||||
v5::TaskType::IndexDeletion => v6::Kind::IndexDeletion,
|
v5::Kind::IndexDeletion => v6::Kind::IndexDeletion,
|
||||||
// TODO: this is a `DocumentAdditionOrUpdate` but we still don't have this type in the `TaskView`.
|
// TODO: this is a `DocumentAdditionOrUpdate` but we still don't have this type in the `TaskView`.
|
||||||
v5::TaskType::DocumentAdditionOrUpdate => v6::Kind::DocumentAddition,
|
v5::Kind::DocumentAdditionOrUpdate => v6::Kind::DocumentAddition,
|
||||||
v5::TaskType::DocumentDeletion => v6::Kind::DocumentDeletion,
|
v5::Kind::DocumentDeletion => v6::Kind::DocumentDeletion,
|
||||||
v5::TaskType::SettingsUpdate => v6::Kind::Settings,
|
v5::Kind::SettingsUpdate => v6::Kind::Settings,
|
||||||
v5::TaskType::DumpCreation => v6::Kind::DumpExport,
|
v5::Kind::DumpCreation => v6::Kind::DumpExport,
|
||||||
},
|
},
|
||||||
details: task_view.details.map(|details| match details {
|
details: task_view.details.map(|details| match details {
|
||||||
v5::TaskDetails::DocumentAddition {
|
v5::Details::DocumentAddition {
|
||||||
received_documents,
|
received_documents,
|
||||||
indexed_documents,
|
indexed_documents,
|
||||||
} => v6::Details::DocumentAddition {
|
} => v6::Details::DocumentAddition {
|
||||||
received_documents: received_documents as u64,
|
received_documents: received_documents as u64,
|
||||||
indexed_documents: indexed_documents.map_or(0, |i| i as u64),
|
indexed_documents: indexed_documents.map_or(0, |i| i as u64),
|
||||||
},
|
},
|
||||||
v5::TaskDetails::Settings { settings } => v6::Details::Settings {
|
v5::Details::Settings { settings } => v6::Details::Settings {
|
||||||
settings: settings.into(),
|
settings: settings.into(),
|
||||||
},
|
},
|
||||||
v5::TaskDetails::IndexInfo { primary_key } => {
|
v5::Details::IndexInfo { primary_key } => {
|
||||||
v6::Details::IndexInfo { primary_key }
|
v6::Details::IndexInfo { primary_key }
|
||||||
}
|
}
|
||||||
v5::TaskDetails::DocumentDeletion {
|
v5::Details::DocumentDeletion {
|
||||||
received_document_ids,
|
received_document_ids,
|
||||||
deleted_documents,
|
deleted_documents,
|
||||||
} => v6::Details::DocumentDeletion {
|
} => v6::Details::DocumentDeletion {
|
||||||
received_document_ids,
|
received_document_ids,
|
||||||
deleted_documents,
|
deleted_documents,
|
||||||
},
|
},
|
||||||
v5::TaskDetails::ClearAll { deleted_documents } => {
|
v5::Details::ClearAll { deleted_documents } => {
|
||||||
v6::Details::ClearAll { deleted_documents }
|
v6::Details::ClearAll { deleted_documents }
|
||||||
}
|
}
|
||||||
v5::TaskDetails::Dump { dump_uid } => v6::Details::Dump { dump_uid },
|
v5::Details::Dump { dump_uid } => v6::Details::Dump { dump_uid },
|
||||||
}),
|
}),
|
||||||
error: task_view.error.map(|e| e.into()),
|
error: task_view.error.map(|e| e.into()),
|
||||||
duration: task_view.duration,
|
duration: task_view.duration,
|
||||||
|
@ -16,17 +16,38 @@ mod tasks;
|
|||||||
|
|
||||||
use crate::{IndexMetadata, Result, Version};
|
use crate::{IndexMetadata, Result, Version};
|
||||||
|
|
||||||
use self::{
|
use self::meta::{DumpMeta, IndexUuid};
|
||||||
keys::Key,
|
|
||||||
meta::{DumpMeta, IndexUuid},
|
|
||||||
settings::{Checked, Settings},
|
|
||||||
tasks::Task,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{/* compat::v4_to_v5::CompatV4ToV5, */ DumpReader, IndexReader};
|
use super::{/* compat::v4_to_v5::CompatV4ToV5, */ DumpReader, IndexReader};
|
||||||
|
|
||||||
pub type Document = serde_json::Map<String, serde_json::Value>;
|
pub type Document = serde_json::Map<String, serde_json::Value>;
|
||||||
|
pub type Settings<T> = settings::Settings<T>;
|
||||||
|
pub type Checked = settings::Checked;
|
||||||
|
pub type Unchecked = settings::Unchecked;
|
||||||
|
|
||||||
|
pub type Task = tasks::Task;
|
||||||
pub type UpdateFile = File;
|
pub type UpdateFile = File;
|
||||||
|
pub type Key = keys::Key;
|
||||||
|
|
||||||
|
// ===== Other types to clarify the code of the compat module
|
||||||
|
// everything related to the tasks
|
||||||
|
pub type Status = tasks::TaskStatus;
|
||||||
|
pub type Kind = tasks::TaskType;
|
||||||
|
pub type Details = tasks::TaskDetails;
|
||||||
|
|
||||||
|
// everything related to the settings
|
||||||
|
pub type Setting<T> = settings::Setting<T>;
|
||||||
|
pub type TypoTolerance = settings::TypoSettings;
|
||||||
|
pub type MinWordSizeForTypos = settings::MinWordSizeTyposSetting;
|
||||||
|
|
||||||
|
// everything related to the api keys
|
||||||
|
pub type Action = keys::Action;
|
||||||
|
pub type StarOr<T> = meta::StarOr<T>;
|
||||||
|
pub type IndexUid = meta::IndexUid;
|
||||||
|
|
||||||
|
// everything related to the errors
|
||||||
|
pub type ResponseError = tasks::ResponseError;
|
||||||
|
pub type Code = meilisearch_types::error::Code;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
@ -52,7 +52,7 @@ pub enum TaskContent {
|
|||||||
#[cfg_attr(test, derive(serde::Serialize))]
|
#[cfg_attr(test, derive(serde::Serialize))]
|
||||||
#[cfg_attr(test, serde(untagged))]
|
#[cfg_attr(test, serde(untagged))]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
enum TaskDetails {
|
pub enum TaskDetails {
|
||||||
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
||||||
DocumentAddition {
|
DocumentAddition {
|
||||||
received_documents: usize,
|
received_documents: usize,
|
||||||
@ -77,7 +77,7 @@ enum TaskDetails {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(serde::Serialize))]
|
#[cfg_attr(test, derive(serde::Serialize))]
|
||||||
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
||||||
enum TaskStatus {
|
pub enum TaskStatus {
|
||||||
Enqueued,
|
Enqueued,
|
||||||
Processing,
|
Processing,
|
||||||
Succeeded,
|
Succeeded,
|
||||||
@ -87,7 +87,7 @@ enum TaskStatus {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(serde::Serialize))]
|
#[cfg_attr(test, derive(serde::Serialize))]
|
||||||
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
#[cfg_attr(test, serde(rename_all = "camelCase"))]
|
||||||
enum TaskType {
|
pub enum TaskType {
|
||||||
IndexCreation,
|
IndexCreation,
|
||||||
IndexUpdate,
|
IndexUpdate,
|
||||||
IndexDeletion,
|
IndexDeletion,
|
||||||
|
@ -47,18 +47,41 @@ use crate::{IndexMetadata, Result, Version};
|
|||||||
|
|
||||||
use super::{compat::v5_to_v6::CompatV5ToV6, DumpReader, IndexReader};
|
use super::{compat::v5_to_v6::CompatV5ToV6, DumpReader, IndexReader};
|
||||||
|
|
||||||
mod keys;
|
pub mod keys;
|
||||||
mod meta;
|
pub mod meta;
|
||||||
mod settings;
|
pub mod settings;
|
||||||
mod tasks;
|
pub mod tasks;
|
||||||
|
|
||||||
pub use keys::*;
|
|
||||||
pub use meta::*;
|
|
||||||
pub use settings::*;
|
|
||||||
pub use tasks::*;
|
|
||||||
|
|
||||||
pub type Document = serde_json::Map<String, serde_json::Value>;
|
pub type Document = serde_json::Map<String, serde_json::Value>;
|
||||||
|
pub type Settings<T> = settings::Settings<T>;
|
||||||
|
pub type Checked = settings::Checked;
|
||||||
|
pub type Unchecked = settings::Unchecked;
|
||||||
|
|
||||||
|
pub type Task = tasks::Task;
|
||||||
pub type UpdateFile = File;
|
pub type UpdateFile = File;
|
||||||
|
pub type Key = keys::Key;
|
||||||
|
|
||||||
|
// ===== Other types to clarify the code of the compat module
|
||||||
|
// everything related to the tasks
|
||||||
|
pub type Status = tasks::TaskStatus;
|
||||||
|
pub type Kind = tasks::TaskType;
|
||||||
|
pub type Details = tasks::TaskDetails;
|
||||||
|
|
||||||
|
// everything related to the settings
|
||||||
|
pub type Setting<T> = settings::Setting<T>;
|
||||||
|
pub type TypoTolerance = settings::TypoSettings;
|
||||||
|
pub type MinWordSizeForTypos = settings::MinWordSizeTyposSetting;
|
||||||
|
pub type FacetingSettings = settings::FacetingSettings;
|
||||||
|
pub type PaginationSettings = settings::PaginationSettings;
|
||||||
|
|
||||||
|
// everything related to the api keys
|
||||||
|
pub type Action = keys::Action;
|
||||||
|
pub type StarOr<T> = meta::StarOr<T>;
|
||||||
|
pub type IndexUid = meta::IndexUid;
|
||||||
|
|
||||||
|
// everything related to the errors
|
||||||
|
pub type ResponseError = tasks::ResponseError;
|
||||||
|
pub type Code = meilisearch_types::error::Code;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@ -75,7 +98,7 @@ pub struct V5Reader {
|
|||||||
metadata: Metadata,
|
metadata: Metadata,
|
||||||
tasks: BufReader<File>,
|
tasks: BufReader<File>,
|
||||||
keys: BufReader<File>,
|
keys: BufReader<File>,
|
||||||
index_uuid: Vec<IndexUuid>,
|
index_uuid: Vec<meta::IndexUuid>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl V5Reader {
|
impl V5Reader {
|
||||||
@ -168,7 +191,7 @@ pub struct V5IndexReader {
|
|||||||
impl V5IndexReader {
|
impl V5IndexReader {
|
||||||
pub fn new(name: String, path: &Path) -> Result<Self> {
|
pub fn new(name: String, path: &Path) -> Result<Self> {
|
||||||
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: meta::DumpMeta = serde_json::from_reader(meta)?;
|
||||||
|
|
||||||
let metadata = IndexMetadata {
|
let metadata = IndexMetadata {
|
||||||
uid: name,
|
uid: name,
|
||||||
|
Loading…
Reference in New Issue
Block a user