feat(stats): add query params for Meilisearch v1.44 showInternalDatabaseSizes and sizeFormat#916
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (2)
📝 WalkthroughWalkthroughThis PR widens Stats and IndexStats size fields to accept ChangesStats API v1.44.0 Feature Support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
| /** | ||
| * @param array{showInternalDatabaseSizes?: bool, sizeFormat?: 'raw'|'human'} $query | ||
| */ | ||
| public function stats(array $query = []): array |
There was a problem hiding this comment.
I'd use request object instead
| * @return int|string | ||
| */ | ||
| public function getRawDocumentDbSize(): int | ||
| public function getRawDocumentDbSize(): int|string |
There was a problem hiding this comment.
@Strift i'd instead tighten the return type to https://github.com/zenstruck/bytes, but not sure if team agrees on using external packages here (when i tried to implem stats command in meilisearch-bundle, i relied on this package, but the stats are not ported to v1 yet IIRC? so i didn't open a PR)
why? because then it's a consumers choice how to format to human readable format, what unit to use, etc.
There was a problem hiding this comment.
This is mainly used for debugging. I don't think it's worth introducing a new dependency for now. Just passing through the data should be fine
There was a problem hiding this comment.
imho the api should have just returned a new field instead of introducing a boolean flag that just changes the response contract, but ok
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #916 +/- ##
==========================================
- Coverage 89.78% 88.30% -1.48%
==========================================
Files 59 93 +34
Lines 1449 1933 +484
==========================================
+ Hits 1301 1707 +406
- Misses 148 226 +78 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #915.
Adds support for the two new query parameters introduced in Meilisearch v1.44.0 for the stats endpoints.
Changes
src/Contracts/Stats.php—databaseSizeandusedDatabaseSizewidened frominttoint|stringto accommodate human-readable responses whensizeFormat='human'src/Contracts/IndexStats.php— same widening forrawDocumentDbSizeandavgDocumentSize; new optionalinternalDatabaseSizes: ?arrayfield (present only whenshowInternalDatabaseSizes=true; keys subject to change per spec)src/Endpoints/Stats.php— overridesshow()to accept a$queryarray passed through tohttp->getsrc/Endpoints/Delegates/HandlesSystem.php—stats(array $query = [])passes query toStats::show()src/Endpoints/Indexes.php—stats(array $query = [])passes query tohttp->get.code-samples.meilisearch.yaml— updatedget_index_stats_1andget_indexes_stats_1All existing callers with no arguments continue to work unchanged.
Summary
This pull request adds support for two new query parameters introduced in Meilisearch v1.44.0 to the stats endpoints:
showInternalDatabaseSizesandsizeFormat.Key Changes
Contracts Updated
databaseSizeandusedDatabaseSizewidened frominttoint|stringto support both raw byte counts and human-readable strings.rawDocumentDbSizeandavgDocumentSizewidened frominttoint|string; added optionalinternalDatabaseSizes: ?array(map of internal DB names to sizes) and agetInternalDatabaseSizes(): ?arraygetter.fromArray()updated to accept the new field.Endpoints and Delegates Enhanced
show(array $query = []): ?arrayto forward query parameters to the HTTP GET for/stats.stats()signature changed tostats(array $query = []): StatsContractand forwards$querytoStats::show().stats(array $query = []): arraynow forwards the query array to the HTTP GET request for index stats.Documentation Samples
get_index_stats_1andget_indexes_stats_1to callstatswithshowInternalDatabaseSizes: trueandsizeFormat: 'human'.Backward Compatibility
All additions are optional and default to prior behavior; callers that invoke
stats()without arguments continue to work unchanged.Related Issues
Closes
#915