From e5a336a042e4c79e36c24c785b0172ff8fb07dc2 Mon Sep 17 00:00:00 2001 From: sgummaluri Date: Sat, 4 Apr 2020 23:18:43 +0530 Subject: [PATCH 1/4] Fix for 'First update does not appear before being processed' #542 --- CHANGELOG.md | 1 + meilisearch-core/src/store/mod.rs | 4 ++-- meilisearch-http/tests/index.rs | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a36808eb4..d1c172ee8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,4 @@ - Add support of nested null, boolean and seq values (#571 and #568, #574) - Fixed the core benchmark (#576) - Publish an ARMv7 and ARMv8 binaries on releases (#540 and #581) + - First update does not appear before being processed (#542) diff --git a/meilisearch-core/src/store/mod.rs b/meilisearch-core/src/store/mod.rs index 0b12f94dc..48bcfcef8 100644 --- a/meilisearch-core/src/store/mod.rs +++ b/meilisearch-core/src/store/mod.rs @@ -334,14 +334,14 @@ impl Index { for id in 0..=last_id { if let Some(update) = self.update_status(reader, id)? { updates.push(update); - last_update_result_id = id; + last_update_result_id = id + 1; } } } // retrieve all enqueued updates if let Some((last_id, _)) = self.updates.last_update(reader)? { - for id in last_update_result_id + 1..=last_id { + for id in last_update_result_id..=last_id { if let Some(update) = self.update_status(reader, id)? { updates.push(update); } diff --git a/meilisearch-http/tests/index.rs b/meilisearch-http/tests/index.rs index ab10cf35b..bfdbdc58a 100644 --- a/meilisearch-http/tests/index.rs +++ b/meilisearch-http/tests/index.rs @@ -1,5 +1,6 @@ use assert_json_diff::assert_json_eq; use serde_json::json; +use serde_json::Value; mod common; @@ -657,3 +658,31 @@ fn check_add_documents_without_primary_key() { assert_eq!(status_code, 400); assert_json_eq!(response, expected, ordered: false); } + +#[test] +fn check_first_update_should_bring_up_enqueued_status_before_processing(){ + let mut server = common::Server::with_uid("movies"); + + let body = json!({ + "uid": "movies", + }); + + // 1. Create Index + let (response, status_code) = server.create_index(body); + assert_eq!(status_code, 201); + assert_eq!(response["primaryKey"], json!(null)); + + let dataset = include_bytes!("assets/movies.json"); + + let body: Value = serde_json::from_slice(dataset).unwrap(); + + // 2. Index the documents from movies.json, present inside of assets directory + server.add_or_replace_multiple_documents(body); + + // 3. Fetch the status of the indexing done above. + let (response, status_code) = server.get_all_updates_status(); + + // 4. Verify the fetch is successful and indexing status is 'processed' + assert_eq!(status_code, 200); + assert_eq!(response[0]["status"], "processed"); +} From a28b428074049d2a051cbdb0c53bfa70434c9fc5 Mon Sep 17 00:00:00 2001 From: Sai Kumar Gummaluri Date: Sun, 5 Apr 2020 00:14:58 +0530 Subject: [PATCH 2/4] Update changelog to make the message more readable --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1c172ee8..96f00c9bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,4 @@ - Add support of nested null, boolean and seq values (#571 and #568, #574) - Fixed the core benchmark (#576) - Publish an ARMv7 and ARMv8 binaries on releases (#540 and #581) - - First update does not appear before being processed (#542) + - Fixing the bug where the result of the update status after the first update was empty (#542) From b4df54197b89554be4b4ffd5a28c65db173099ca Mon Sep 17 00:00:00 2001 From: Sai Kumar Gummaluri Date: Sun, 5 Apr 2020 00:17:47 +0530 Subject: [PATCH 3/4] Slight grammar modification to the changelog message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96f00c9bb..f5af34c0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,4 @@ - Add support of nested null, boolean and seq values (#571 and #568, #574) - Fixed the core benchmark (#576) - Publish an ARMv7 and ARMv8 binaries on releases (#540 and #581) - - Fixing the bug where the result of the update status after the first update was empty (#542) + - Fixing a bug where the result of the update status after the first update was empty (#542) From 16a63c74ea28c8902057a06986fe1dc0fd0ddc08 Mon Sep 17 00:00:00 2001 From: Sai Kumar Gummaluri Date: Sun, 5 Apr 2020 00:26:09 +0530 Subject: [PATCH 4/4] Modifying the test name for better readability --- meilisearch-http/tests/index.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meilisearch-http/tests/index.rs b/meilisearch-http/tests/index.rs index bfdbdc58a..e0b44b9b5 100644 --- a/meilisearch-http/tests/index.rs +++ b/meilisearch-http/tests/index.rs @@ -660,7 +660,7 @@ fn check_add_documents_without_primary_key() { } #[test] -fn check_first_update_should_bring_up_enqueued_status_before_processing(){ +fn check_first_update_should_bring_up_processed_status_after_first_docs_addition(){ let mut server = common::Server::with_uid("movies"); let body = json!({