-
Notifications
You must be signed in to change notification settings - Fork 102
Add batchStrategy field to batches #722
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
WalkthroughAdds a new Batches API: a public Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Client
participant QueryBuilder
participant HTTP
rect rgba(200,230,255,0.35)
User->>Client: get_batches()
Client->>HTTP: GET /batches
HTTP-->>Client: 200 + BatchesResults
Client-->>User: Ok(BatchesResults)
end
rect rgba(220,255,200,0.35)
User->>Client: get_batches_with(query)
Client->>QueryBuilder: read limit/from
QueryBuilder-->>Client: query params
Client->>HTTP: GET /batches?limit=X&from=Y
HTTP-->>Client: 200 + BatchesResults
Client-->>User: Ok(BatchesResults)
end
rect rgba(255,230,200,0.35)
User->>Client: get_batch(uid)
Client->>HTTP: GET /batches/{uid}
HTTP-->>Client: 200 + Batch
Client-->>User: Ok(Batch)
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (2)src/client.rs (1)
src/batches.rs (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (8)
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. Comment |
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: 1
🧹 Nitpick comments (7)
.code-samples.meilisearch.yaml (2)
452-457: Consider showcasing paginated usageAdd an example using
BatchesQuery(with_limit,with_from) to mirror other paginated samples and the new API.get_all_batches_1: |- - let batches: BatchesResults = client - .get_batches() - .await - .unwrap(); + let mut query = meilisearch_sdk::batches::BatchesQuery::new(&client); + query.with_limit(20); + let batches: meilisearch_sdk::batches::BatchesResults = + client.get_batches_with(&query).await.unwrap();
458-461: Minor: clarify uid type in the exampleUse a named
u32variable to hint the expected type (helps readers).get_batch_1: |- - let batch: Batch = client - .get_batch(42) + let uid: u32 = 42; + let batch: meilisearch_sdk::batches::Batch = client + .get_batch(uid) .await .unwrap();src/client.rs (1)
1115-1157: Add small doctest snippets for parity with other client methodsFollow existing style by adding minimal examples to
get_batches,get_batches_with, andget_batchto keep docs cohesive and catch regressions.src/batches.rs (4)
30-35: Type safety forbatch_strategyIf the set of values is known/stable (e.g.,
time_limit_reached,size_limit_reached), prefer an enum with#[serde(rename_all = "snake_case")]for compile-time safety. KeepOption<...>if it’s not always present.
39-49: Align pagination field types with existing Results structsFor consistency with other SDK results (e.g., indexes/tasks), consider using the same integer widths (often
u32) fortotal,limit,from,nextunless the API guarantees wider ranges.
65-91: Query builder looks good; add a query-serialization testImplementation mirrors other builders. Add a test asserting the presence of
?limit=/?from=in the request (via mockito matchers) to lock the wire format.// sketch let _m = s.mock("GET", "/batches") .match_query(Matcher::AllOf(vec![ Matcher::UrlEncoded("limit".into(), "2".into()), Matcher::UrlEncoded("from".into(), "40".into()), ])) .with_status(200).with_body(r#"{"results":[]}"#).create_async().await;
137-161: Tests: single-batch retrieval OKCovers minimal payload. Consider adding a case with missing optional fields to ensure defaults behave as expected.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.code-samples.meilisearch.yaml(1 hunks)src/batches.rs(1 hunks)src/client.rs(1 hunks)src/lib.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/client.rs (1)
src/request.rs (1)
query(39-47)
src/batches.rs (1)
src/client.rs (1)
new(54-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: integration-tests
🔇 Additional comments (3)
src/lib.rs (1)
233-234: Module exposure looks goodPublicly exporting
batcheswith a brief doc is consistent with the crate’s layout.src/client.rs (1)
1115-1157: Batches endpoints wiring is correctHTTP method, paths, and status codes are consistent with existing patterns.
src/batches.rs (1)
97-135: Tests: happy-path coverage is solidGood coverage for parsing timestamps and
batchStrategy.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #722 +/- ##
==========================================
+ Coverage 86.18% 86.41% +0.22%
==========================================
Files 20 21 +1
Lines 6263 6388 +125
==========================================
+ Hits 5398 5520 +122
- Misses 865 868 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Pull Request
Related issue
Fixes #671
What does this PR do?
.code-samples.meilisearch.yamlPR checklist
Please check if your PR fulfills the following requirements:
Thank you so much for contributing to Meilisearch!
Summary by CodeRabbit
New Features
Tests