mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
Add status failed on UpdateStatus
This commit is contained in:
parent
9640c2aaa6
commit
3a90233a3d
@ -461,7 +461,7 @@ mod tests {
|
|||||||
|
|
||||||
let update_reader = db.update_read_txn().unwrap();
|
let update_reader = db.update_read_txn().unwrap();
|
||||||
let result = index.update_status(&update_reader, update_id).unwrap();
|
let result = index.update_status(&update_reader, update_id).unwrap();
|
||||||
assert_matches!(result, Some(UpdateStatus::Processed { content }) if content.error.is_some());
|
assert_matches!(result, Some(UpdateStatus::Failed { content }) if content.error.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -685,7 +685,7 @@ mod tests {
|
|||||||
// check if it has been accepted
|
// check if it has been accepted
|
||||||
let update_reader = db.update_read_txn().unwrap();
|
let update_reader = db.update_read_txn().unwrap();
|
||||||
let result = index.update_status(&update_reader, update_id).unwrap();
|
let result = index.update_status(&update_reader, update_id).unwrap();
|
||||||
assert_matches!(result, Some(UpdateStatus::Processed { content }) if content.error.is_some());
|
assert_matches!(result, Some(UpdateStatus::Failed { content }) if content.error.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -197,6 +197,10 @@ pub enum UpdateStatus {
|
|||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
content: EnqueuedUpdateResult,
|
content: EnqueuedUpdateResult,
|
||||||
},
|
},
|
||||||
|
Failed {
|
||||||
|
#[serde(flatten)]
|
||||||
|
content: ProcessedUpdateResult,
|
||||||
|
},
|
||||||
Processed {
|
Processed {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
content: ProcessedUpdateResult,
|
content: ProcessedUpdateResult,
|
||||||
@ -210,7 +214,13 @@ pub fn update_status(
|
|||||||
update_id: u64,
|
update_id: u64,
|
||||||
) -> MResult<Option<UpdateStatus>> {
|
) -> MResult<Option<UpdateStatus>> {
|
||||||
match updates_results_store.update_result(update_reader, update_id)? {
|
match updates_results_store.update_result(update_reader, update_id)? {
|
||||||
Some(result) => Ok(Some(UpdateStatus::Processed { content: result })),
|
Some(result) => {
|
||||||
|
if result.error.is_some() {
|
||||||
|
Ok(Some(UpdateStatus::Failed { content: result }))
|
||||||
|
} else {
|
||||||
|
Ok(Some(UpdateStatus::Processed { content: result }))
|
||||||
|
}
|
||||||
|
},
|
||||||
None => match updates_store.get(update_reader, update_id)? {
|
None => match updates_store.get(update_reader, update_id)? {
|
||||||
Some(update) => Ok(Some(UpdateStatus::Enqueued {
|
Some(update) => Ok(Some(UpdateStatus::Enqueued {
|
||||||
content: EnqueuedUpdateResult {
|
content: EnqueuedUpdateResult {
|
||||||
|
Loading…
Reference in New Issue
Block a user