feat(entities): add grouped count queries - #837
Conversation
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
|
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughChangesEntity listing now accepts Entity grouped counts
Sequence Diagram(s)sequenceDiagram
participant EntityClient
participant list_entities
participant SQLAlchemyEntityRepository
EntityClient->>list_entities: Request entities with count_by and filter
list_entities->>SQLAlchemyEntityRepository: List filtered entities
list_entities->>SQLAlchemyEntityRepository: Count entities by direct string field
SQLAlchemyEntityRepository-->>list_entities: Entities and group counts
list_entities-->>EntityClient: EntitiesPage with group_counts
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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
`@services/core/entities/src/nmp/core/entities/app/repository/sqlalchemy/entity.py`:
- Around line 219-220: Replace the cast-and-trim logic in the grouped-value path
of the entity repository with the dialect-aware JSON scalar extractor so escaped
quotes and backslashes decode correctly. In
services/core/entities/src/nmp/core/entities/app/repository/sqlalchemy/entity.py:219-220,
update the expression assigned to group_column while preserving
raw_group_column. Add a regression case in
services/core/entities/tests/repository/test_entity_group_counts.py:18-26
covering quoted and backslash-containing insight_id values and asserting their
decoded grouped counts.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: cd7731cc-6957-4811-adf5-a8179070c190
📒 Files selected for processing (10)
openapi/ga/individual/platform.openapi.yamlopenapi/ga/openapi.yamlopenapi/openapi.yamlpackages/nemo_platform_plugin/src/nemo_platform_plugin/entities.pypackages/nemo_platform_plugin/tests/test_entity_client.pyservices/core/entities/src/nmp/core/entities/api/v2/entities/endpoints.pyservices/core/entities/src/nmp/core/entities/app/repository/entity.pyservices/core/entities/src/nmp/core/entities/app/repository/sqlalchemy/entity.pyservices/core/entities/tests/integration/test_generic_entities.pyservices/core/entities/tests/repository/test_entity_group_counts.py
walston
left a comment
There was a problem hiding this comment.
You've got a couple failing CI checks, and Coderabbit called out an apparently valid(?) issue.
Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
maxdubrinsky
left a comment
There was a problem hiding this comment.
Looks good to me once tests are passing.
Features like this have been pondered in the past, and we might want to look at expanding this out into a more comprehensive set of grouping functions. Don't think we need to go full aggregation pipelines, but I could see other operations being useful on the plugin/studio side.
* feat(entities): add grouped entity counts Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * feat(entities): expose grouped counts in list API Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * feat(entities): add client count helper Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * refactor(entities): simplify grouped count implementation Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * chore(openapi): refresh entity grouped counts contract Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * fix(entities): harden grouped count results Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * fix(entities): validate grouped count fields Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * fix(entities): preserve null string group keys Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * docs: narrow entity grouped count design Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * refactor(entities): narrow grouped counts Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * fix(entities): validate empty count field Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * refactor(entities): narrow grouped count client Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * chore(entities): finalize narrow grouped counts Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * chore(entities): apply final-review cleanup to grouped counts Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> * fix(entities): decode grouped JSON string values Signed-off-by: Aditya Pandey <aditypandey@nvidia.com> --------- Signed-off-by: Aditya Pandey <aditypandey@nvidia.com>
Summary
EntityClient.count_by()Test plan
97 passed, 1 skippedacross focused repository, API, and client suitesContext
This is an independent platform capability proposed while reviewing #757. It intentionally contains no Insights or Studio consumer changes.
Summary by CodeRabbit
count_byparameter to the entities listing endpoint to return counts grouped by a direct string data field.group_counts(group key → integer count) whencount_byis provided.