Add human-formatted sizes and internal database sizes to stats#1257
Add human-formatted sizes and internal database sizes to stats#1257qorexdevs wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughClient.get_all_stats and Index.get_stats now accept optional show_internal_database_sizes and size_format parameters, building query strings appended to the stats endpoints. IndexStats model adds raw_database_size and internal_database_sizes optional fields. New tests validate human-formatted sizes and internal database size responses for both client and index stats. ChangesStats API Query Parameter Support
Sequence Diagram(s)sequenceDiagram
participant Caller
participant ClientOrIndex
participant MeilisearchAPI
Caller->>ClientOrIndex: get_all_stats/get_stats(show_internal_database_sizes, size_format)
ClientOrIndex->>ClientOrIndex: build query parameters dict
ClientOrIndex->>MeilisearchAPI: GET stats endpoint with encoded query
MeilisearchAPI-->>ClientOrIndex: stats response (with internalDatabaseSizes/human sizes)
ClientOrIndex-->>Caller: parsed stats result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
meilisearch/models/index.py (1)
28-35: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
raw_database_sizedoesn't match the stats payload, and it needs to accept human-formatted strings. Meilisearch returnsrawDocumentDbSize, so this field won't populate as written.sizeFormat="human"also turns database sizes into strings, soint | Nonewill reject valid responses.🤖 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 `@meilisearch/models/index.py` around lines 28 - 35, The IndexStats model is using a field type/name that does not match Meilisearch’s stats payload, so the raw database size value will not bind correctly. Update IndexStats in the model definition to map the rawDocumentDbSize response key to the existing raw_database_size field, and change its type so it can accept both numeric values and human-formatted strings returned when sizeFormat="human" is used. Keep the same adjustment consistent with the other stats fields in IndexStats.
🧹 Nitpick comments (1)
tests/index/test_index_stats_meilisearch.py (1)
20-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLGTM! Once the
raw_database_sizefield/type is fixed inmeilisearch/models/index.py, consider adding a companion test callingget_stats(size_format="human")to lock in thatIndexStatsstill validates correctly.🤖 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 `@tests/index/test_index_stats_meilisearch.py` around lines 20 - 25, The existing stats test only covers show_internal_database_sizes, so add a companion test around IndexStats validation for the human-sized path once raw_database_size is fixed in meilisearch/models/index.py. Reuse the get_stats entry point in test_get_stats_internal_database_sizes and add coverage for get_stats(size_format="human") to verify the response still instantiates IndexStats and validates the database size field/type correctly.
🤖 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.
Outside diff comments:
In `@meilisearch/models/index.py`:
- Around line 28-35: The IndexStats model is using a field type/name that does
not match Meilisearch’s stats payload, so the raw database size value will not
bind correctly. Update IndexStats in the model definition to map the
rawDocumentDbSize response key to the existing raw_database_size field, and
change its type so it can accept both numeric values and human-formatted strings
returned when sizeFormat="human" is used. Keep the same adjustment consistent
with the other stats fields in IndexStats.
---
Nitpick comments:
In `@tests/index/test_index_stats_meilisearch.py`:
- Around line 20-25: The existing stats test only covers
show_internal_database_sizes, so add a companion test around IndexStats
validation for the human-sized path once raw_database_size is fixed in
meilisearch/models/index.py. Reuse the get_stats entry point in
test_get_stats_internal_database_sizes and add coverage for
get_stats(size_format="human") to verify the response still instantiates
IndexStats and validates the database size field/type correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c4126e78-67f1-4a29-86d8-17287a6b5cf2
📒 Files selected for processing (5)
meilisearch/client.pymeilisearch/index.pymeilisearch/models/index.pytests/client/test_client_stats_meilisearch.pytests/index/test_index_stats_meilisearch.py
|
just realized #1237 already covers #1234 with the same two params and it predates this - closing mine so it doesn't split the review. sorry for the noise @vivek378521, yours should land. |
Related issue
Closes #1234
What does this PR do?
show_internal_database_sizesandsize_formatparams toclient.get_all_stats()andIndex.get_stats(), sent as theshowInternalDatabaseSizesandsizeFormatquery params introduced in Meilisearch 1.44internalDatabaseSizes(andrawDatabaseSize) keys on theIndexStatsmodel as optional fields, so nothing breaks when they are absentAI disclosure
None
PR checklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests