Add stats size format options#979
Conversation
📝 WalkthroughWalkthroughThis PR adds ChangesStats query parameter support
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/com/meilisearch/sdk/StatsTest.java (1)
33-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for optional/default and raw-size responses.
These tests only exercise the
sizeFormat=humanpath and a fully populated query. They never cover the API’s optional/default behavior or raw numeric size payloads, so the currentsizeFormat=nullserialization bug slips through and half of the new response contract remains unverified.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/meilisearch/sdk/StatsTest.java` around lines 33 - 120, Add test coverage in StatsTest for the missing StatsQuery paths: verify the default/optional case where sizeFormat is not set still serializes correctly and does not emit a null query value, and add raw-size response coverage for both client.getStats and client.index("movies").getStats using numeric size payloads rather than only the human-formatted contract. Use the existing StatsQuery, getStatsWithQueryParameters, getIndexStatsWithQueryParameters, and statsQuerySerializesParameters tests as the place to extend assertions so the serialization bug and raw response handling are both exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/com/meilisearch/sdk/model/StatsQuery.java`:
- Around line 22-29: The StatsQuery.toQuery() serialization currently always
adds sizeFormat, which produces an unwanted null query value when it is unset.
Update toQuery() so it only calls URLBuilder.addParameter("sizeFormat", ...)
when getSizeFormat() is non-null/non-empty, while keeping
showInternalDatabaseSizes behavior unchanged. Use the StatsQuery and URLBuilder
symbols to locate the optional-parameter handling and align it with the new
contract.
---
Nitpick comments:
In `@src/test/java/com/meilisearch/sdk/StatsTest.java`:
- Around line 33-120: Add test coverage in StatsTest for the missing StatsQuery
paths: verify the default/optional case where sizeFormat is not set still
serializes correctly and does not emit a null query value, and add raw-size
response coverage for both client.getStats and client.index("movies").getStats
using numeric size payloads rather than only the human-formatted contract. Use
the existing StatsQuery, getStatsWithQueryParameters,
getIndexStatsWithQueryParameters, and statsQuerySerializesParameters tests as
the place to extend assertions so the serialization bug and raw response
handling are both exercised.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b537f053-e8f8-49e8-b95c-4bb90a6a4576
📒 Files selected for processing (8)
.code-samples.meilisearch.yamlsrc/main/java/com/meilisearch/sdk/Client.javasrc/main/java/com/meilisearch/sdk/Index.javasrc/main/java/com/meilisearch/sdk/InstanceHandler.javasrc/main/java/com/meilisearch/sdk/model/IndexStatsWithSizeFormat.javasrc/main/java/com/meilisearch/sdk/model/StatsQuery.javasrc/main/java/com/meilisearch/sdk/model/StatsWithSizeFormat.javasrc/test/java/com/meilisearch/sdk/StatsTest.java
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/test/java/com/meilisearch/sdk/StatsTest.java (1)
114-191: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting shared JSON fixtures/assertions.
getStatsWithRawSizeResponse/getIndexStatsWithRawSizeResponselargely duplicate the structure ofgetStatsWithQueryParameters/getIndexStatsWithQueryParameters(same JSON shape, same assertions, just numeric vs. string values). A small helper (e.g., parameterizing size values or extracting a common request/response verification method) would reduce duplication, but the current tests are correct and readable as-is.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/test/java/com/meilisearch/sdk/StatsTest.java` around lines 114 - 191, The two new stats tests duplicate the same response shape and assertion pattern already covered by the existing query-parameter tests, so the main issue is avoidable test repetition. Extract a shared helper in StatsTest for building the stats JSON and verifying the common fields/request path, or parameterize the size values so getStatsWithRawSizeResponse and getIndexStatsWithRawSizeResponse reuse the same setup/assertion logic while keeping the raw-size-specific checks in place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/test/java/com/meilisearch/sdk/StatsTest.java`:
- Around line 114-191: The two new stats tests duplicate the same response shape
and assertion pattern already covered by the existing query-parameter tests, so
the main issue is avoidable test repetition. Extract a shared helper in
StatsTest for building the stats JSON and verifying the common fields/request
path, or parameterize the size values so getStatsWithRawSizeResponse and
getIndexStatsWithRawSizeResponse reuse the same setup/assertion logic while
keeping the raw-size-specific checks in place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bb971aea-61b1-46d3-b4db-55c4791d676a
📒 Files selected for processing (2)
src/main/java/com/meilisearch/sdk/model/StatsQuery.javasrc/test/java/com/meilisearch/sdk/StatsTest.java
🚧 Files skipped from review as they are similar to previous changes (1)
- src/main/java/com/meilisearch/sdk/model/StatsQuery.java
|
Thanks for the review. Since the duplicated setup keeps the raw-size and human-size cases explicit and readable, I’ll leave this as-is for now unless maintainers prefer a helper-based refactor. |
Pull Request
Related issue
Fixes #966
What does this PR do?
StatsQuerysupport for theshowInternalDatabaseSizesandsizeFormatquery parameters.internalDatabaseSizesas a flexible map..code-samples.meilisearch.yamlforget_index_stats_1andget_indexes_stats_1.PR checklist
Please check if your PR fulfills the following requirements:
Tests
.\gradlew.bat testClasses.\gradlew.bat test --tests com.meilisearch.sdk.StatsTest --init-script <disable-jacoco> -x jacocoTestReport -x jacocoTestCoverageVerification --rerun-tasksThank you so much for contributing to Meilisearch!
Summary by CodeRabbit