mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
Implement the status and type filtering on the tasks route
This commit is contained in:
parent
3684c822f1
commit
8509243e68
4 changed files with 185 additions and 11 deletions
|
@ -52,9 +52,9 @@ impl From<TaskContent> for TaskType {
|
|||
}
|
||||
|
||||
impl FromStr for TaskType {
|
||||
type Err = &'static str;
|
||||
type Err = String;
|
||||
|
||||
fn from_str(status: &str) -> Result<Self, &'static str> {
|
||||
fn from_str(status: &str) -> Result<Self, String> {
|
||||
match status {
|
||||
"indexCreation" => Ok(TaskType::IndexCreation),
|
||||
"indexUpdate" => Ok(TaskType::IndexUpdate),
|
||||
|
@ -64,7 +64,12 @@ impl FromStr for TaskType {
|
|||
"documentDeletion" => Ok(TaskType::DocumentDeletion),
|
||||
"settingsUpdate" => Ok(TaskType::SettingsUpdate),
|
||||
"clearAll" => Ok(TaskType::ClearAll),
|
||||
_ => Err("invalid task type value"),
|
||||
unknown => Err(format!(
|
||||
"invalid task type `{}` value, expecting one of: \
|
||||
indexCreation, indexUpdate, indexDeletion, documentAddition, \
|
||||
documentPartial, documentDeletion, settingsUpdate, or clearAll",
|
||||
unknown
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,15 +84,19 @@ pub enum TaskStatus {
|
|||
}
|
||||
|
||||
impl FromStr for TaskStatus {
|
||||
type Err = &'static str;
|
||||
type Err = String;
|
||||
|
||||
fn from_str(status: &str) -> Result<Self, &'static str> {
|
||||
fn from_str(status: &str) -> Result<Self, String> {
|
||||
match status {
|
||||
"enqueued" => Ok(TaskStatus::Enqueued),
|
||||
"processing" => Ok(TaskStatus::Processing),
|
||||
"succeeded" => Ok(TaskStatus::Succeeded),
|
||||
"failed" => Ok(TaskStatus::Failed),
|
||||
_ => Err("invalid task status value"),
|
||||
unknown => Err(format!(
|
||||
"invalid task status `{}` value, expecting one of: \
|
||||
enqueued, processing, succeeded, or failed",
|
||||
unknown
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue