From 737c82ccd2542fe113729171ab70f6487a25cda3 Mon Sep 17 00:00:00 2001 From: Kashif Soofi Date: Fri, 13 Oct 2023 11:17:19 +0100 Subject: [PATCH 1/4] #462: Total tasks in task route --- src/Meilisearch/TasksResults.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Meilisearch/TasksResults.cs b/src/Meilisearch/TasksResults.cs index 8b0601d3..01977b79 100644 --- a/src/Meilisearch/TasksResults.cs +++ b/src/Meilisearch/TasksResults.cs @@ -9,7 +9,7 @@ namespace Meilisearch /// Type of the Meilisearch server object. Ex: keys, indexes, ... public class TasksResults : Result { - public TasksResults(T results, int? limit, int? from, int? next) + public TasksResults(T results, int? limit, int? from, int? next, int? total) : base(results, limit) { From = from; @@ -25,5 +25,10 @@ public TasksResults(T results, int? limit, int? from, int? next) /// Gets next size. /// public int? Next { get; } + + /// + /// Gets total number of tasks. + /// + public int? Total { get; } } } From e668a17cfa0714b95c2268c5b1d6c4907385a2a9 Mon Sep 17 00:00:00 2001 From: Kashif Soofi Date: Wed, 18 Oct 2023 12:15:00 +0100 Subject: [PATCH 2/4] #462: Update test to assert on Total --- tests/Meilisearch.Tests/TaskInfoTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Meilisearch.Tests/TaskInfoTests.cs b/tests/Meilisearch.Tests/TaskInfoTests.cs index f82cb5cf..c2cfa76f 100644 --- a/tests/Meilisearch.Tests/TaskInfoTests.cs +++ b/tests/Meilisearch.Tests/TaskInfoTests.cs @@ -45,6 +45,7 @@ public async Task GetMultipleTaskInfoFromIndex() { await _index.AddDocumentsAsync(new[] { new Movie { Id = "1" } }); var taskResponse = await _index.GetTasksAsync(); + taskResponse.Total.Should().Be(1); var tasks = taskResponse.Results.Where(t => t.IndexUid != _index.Uid); taskResponse.Results.Count().Should().BeGreaterOrEqualTo(1); From 9b436ddfc38a6602dd86c47fca356f60ecfd8eb4 Mon Sep 17 00:00:00 2001 From: Kashif Soofi Date: Wed, 18 Oct 2023 12:26:26 +0100 Subject: [PATCH 3/4] Remove total field verification --- tests/Meilisearch.Tests/TaskInfoTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Meilisearch.Tests/TaskInfoTests.cs b/tests/Meilisearch.Tests/TaskInfoTests.cs index c2cfa76f..f82cb5cf 100644 --- a/tests/Meilisearch.Tests/TaskInfoTests.cs +++ b/tests/Meilisearch.Tests/TaskInfoTests.cs @@ -45,7 +45,6 @@ public async Task GetMultipleTaskInfoFromIndex() { await _index.AddDocumentsAsync(new[] { new Movie { Id = "1" } }); var taskResponse = await _index.GetTasksAsync(); - taskResponse.Total.Should().Be(1); var tasks = taskResponse.Results.Where(t => t.IndexUid != _index.Uid); taskResponse.Results.Count().Should().BeGreaterOrEqualTo(1); From b2c903726f4f1ec4cfaefa8ff9118ffc2b6e055f Mon Sep 17 00:00:00 2001 From: Kashif Soofi Date: Tue, 28 Nov 2023 22:07:37 +0000 Subject: [PATCH 4/4] #462 Set and Verify Total in test --- src/Meilisearch/TasksResults.cs | 1 + tests/Meilisearch.Tests/TaskInfoTests.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Meilisearch/TasksResults.cs b/src/Meilisearch/TasksResults.cs index 01977b79..680c803a 100644 --- a/src/Meilisearch/TasksResults.cs +++ b/src/Meilisearch/TasksResults.cs @@ -14,6 +14,7 @@ public TasksResults(T results, int? limit, int? from, int? next, int? total) { From = from; Next = next; + Total = total; } /// diff --git a/tests/Meilisearch.Tests/TaskInfoTests.cs b/tests/Meilisearch.Tests/TaskInfoTests.cs index f82cb5cf..3f1f4fc1 100644 --- a/tests/Meilisearch.Tests/TaskInfoTests.cs +++ b/tests/Meilisearch.Tests/TaskInfoTests.cs @@ -68,6 +68,7 @@ public async Task GetMultipleTaskInfoWithQueryParameters() var taskResponse = await _index.GetTasksAsync(new TasksQuery { Limit = 1, IndexUids = new List { _index.Uid } }); taskResponse.Results.Count().Should().BeGreaterOrEqualTo(1); + taskResponse.Total.Should().BeGreaterThan(0); } [Fact]