Merge pull request #57 from meilisearch/remove-duplicated-pending-update

remove duplicated pending update
This commit is contained in:
marin 2021-03-05 19:17:57 +01:00 committed by GitHub
commit b8ebf07555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -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)))

View File

@ -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");