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 (6)
📝 WalkthroughWalkthroughThis PR extends the Meilisearch PHP SDK to support v1.44.0's new stats features: human-formatted database sizes and detailed internal database size breakdowns. Data contracts now accept ChangesStats API v1.44.0 Feature Support
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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.
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 Sentry. 🚀 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:
Stats.php:databaseSizeandusedDatabaseSizetypes changed frominttoint|stringto support both byte counts and human-readable strings.IndexStats.php:rawDocumentDbSizeandavgDocumentSizetypes changed frominttoint|string; added new optionalinternalDatabaseSizesproperty (array mapping internal database names to their sizes).Endpoints and Delegates Enhanced:
Stats.php: Addedshow(array $query = []): ?arraymethod to forward query parameters to HTTP GET request.HandlesSystem.php:stats()method now accepts optional$queryparameter and forwards it toStats::show().Indexes.php:stats()method now accepts optional$queryparameter and forwards it to the HTTP GET request.Documentation:
.code-samples.meilisearch.yaml: Updatedget_index_stats_1andget_indexes_stats_1examples to demonstrate callingstats()withshowInternalDatabaseSizes: trueandsizeFormat: 'human'parameters.Backward Compatibility
All changes are backward compatible. Existing code that calls
stats()without arguments continues to work unchanged, as all new parameters are optional with default values.Related Issues
Closes issue
#915