mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 10:37:41 +08:00
Merge pull request #57 from meilisearch/remove-duplicated-pending-update
remove duplicated pending update
This commit is contained in:
commit
b8ebf07555
@ -103,11 +103,21 @@ impl IndexController for LocalIndexController {
|
|||||||
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus<UpdateMeta, UpdateResult, String>>> {
|
||||||
match self.indexes.index(&index)? {
|
match self.indexes.index(&index)? {
|
||||||
Some((_, update_store)) => {
|
Some((_, update_store)) => {
|
||||||
let updates = update_store.iter_metas(|processing, processed, pending, aborted, failed| {
|
let updates = update_store.iter_metas(|processing, processed, aborted, pending, failed| {
|
||||||
|
let processing_id = processing
|
||||||
|
.as_ref()
|
||||||
|
.map(|p| p.id());
|
||||||
|
|
||||||
Ok(processing
|
Ok(processing
|
||||||
.map(UpdateStatus::from)
|
.map(UpdateStatus::from)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.chain(pending.filter_map(|p| p.ok()).map(|(_, u)| UpdateStatus::from(u)))
|
.chain(pending.
|
||||||
|
filter_map(Result::ok)
|
||||||
|
// If an update is processing, filter out this update from the pending
|
||||||
|
// updates.
|
||||||
|
.filter(|(_, u)| processing_id
|
||||||
|
.map_or(true, |id| id != u.id()))
|
||||||
|
.map(|(_, u)| UpdateStatus::from(u)))
|
||||||
.chain(aborted.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
.chain(aborted.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||||
.chain(processed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
.chain(processed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||||
.chain(failed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
.chain(failed.filter_map(Result::ok).map(|(_, u)| UpdateStatus::from(u)))
|
||||||
|
@ -50,9 +50,7 @@ async fn list_no_updates() {
|
|||||||
assert!(response.as_array().unwrap().is_empty());
|
assert!(response.as_array().unwrap().is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: fix #32
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
#[ignore]
|
|
||||||
async fn list_updates() {
|
async fn list_updates() {
|
||||||
let server = Server::new().await;
|
let server = Server::new().await;
|
||||||
let index = server.index("test");
|
let index = server.index("test");
|
||||||
|
Loading…
Reference in New Issue
Block a user