-
Notifications
You must be signed in to change notification settings - Fork 70
Add reverse as a parameter to fetch and sort tasks by the time enqueued #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdded an optional reverseOrder parameter to Index.GetTasksAsync to allow client-side ordering of returned tasks by EnqueuedAt when true; included System.Linq, updated XML docs, and added a unit test validating task ordering when reverseOrder is enabled. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant Index
participant MeiliAPI
Caller->>Index: GetTasksAsync(query, cancellationToken, reverseOrder)
activate Index
Index->>MeiliAPI: GET /tasks (with query)
MeiliAPI-->>Index: TasksResults { Results[], Limit, From, Next, Total }
alt reverseOrder == true
Note over Index: Order Results by EnqueuedAt (ascending) using LINQ
Index-->>Caller: TasksResults { ordered Results, meta preserved }
else reverseOrder == false
Index-->>Caller: TasksResults { original Results, meta preserved }
end
deactivate Index
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (3)
tests/Meilisearch.Tests/TaskInfoTests.cs (1)
110-112
: Reduce flakiness: ensure distinct EnqueuedAt timestamps.Back-to-back enqueues can share the same timestamp, making sort order non-deterministic. Add small delays between enqueues.
- var task1 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "6" } }); - var task2 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "7" } }); - var task3 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "8" } }); + var task1 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "6" } }); + await Task.Delay(50); + var task2 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "7" } }); + await Task.Delay(50); + var task3 = await _index.AddDocumentsAsync(new[] { new Movie { Id = "8" } });src/Meilisearch/Index.Tasks.cs (2)
17-17
: Clarify semantics of reverseOrder.“Reverse the order of the tasks by EnqueuedAt” is ambiguous (reverse of server default vs. explicit direction). If the intent is “newest first,” document it explicitly.
- /// <param name="reverseOrder">Whether to reverse the order of the tasks by EnqueuedAt.</param> + /// <param name="reverseOrder"> + /// If true, return results ordered by EnqueuedAt descending (newest first). If false, preserve server order. + /// Note: pagination fields (From/Next) still reflect server ordering. + /// </param>
17-33
: Server-side sort is preferable to client-side reordering.Client-side resorting breaks global ordering across pages. If the Tasks API supports sort (e.g., by enqueuedAt asc/desc), surface it in TasksQuery and pass it through TaskEndpoint to keep pagination consistent.
I can draft a follow-up PR adding a Sort or OrderBy option to TasksQuery and wiring it into TaskEndpoint.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
src/Meilisearch/Index.Tasks.cs
(2 hunks)tests/Meilisearch.Tests/TaskInfoTests.cs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/Meilisearch.Tests/TaskInfoTests.cs (2)
src/Meilisearch/Index.Tasks.cs (3)
Task
(19-33)Task
(41-44)Task
(54-61)src/Meilisearch/TaskEndpoint.cs (6)
Task
(27-32)Task
(40-47)Task
(55-62)Task
(70-74)Task
(82-86)Task
(96-117)
src/Meilisearch/Index.Tasks.cs (5)
src/Meilisearch/TasksResults.cs (2)
TasksResults
(10-34)TasksResults
(12-18)src/Meilisearch/TaskResource.cs (2)
TaskResource
(10-87)TaskResource
(12-26)src/Meilisearch/QueryParameters/TasksQuery.cs (1)
TasksQuery
(9-75)src/Meilisearch/TaskEndpoint.cs (2)
TaskEndpoint
(17-130)TaskEndpoint
(125-129)src/Meilisearch/Index.cs (1)
TaskEndpoint
(148-157)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Pull Request
Related issue
Fixes #597
What does this PR do?
PR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit