Skip to content

feat(spp_metric_service): breakdown expansion + SQL column support (re-land from #76)#279

Open
gonzalesedwin1123 wants to merge 3 commits into
reland/cel-domainfrom
reland/metric-service
Open

feat(spp_metric_service): breakdown expansion + SQL column support (re-land from #76)#279
gonzalesedwin1123 wants to merge 3 commits into
reland/cel-domainfrom
reland/metric-service

Conversation

@gonzalesedwin1123

@gonzalesedwin1123 gonzalesedwin1123 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Re-lands the spp_metric_service portion of reverted PR #76 (revert: #271). Wave 2 — stacked on #275 (spp_cel_domain); merge that first. The base is set to reland/cel-domain so this diff shows only spp_metric_service; GitHub retargets to 19.0 when #275 merges — wait for CI to re-run green on the retargeted base before merging.

Summary

  • Demographic breakdown expansion and SQL column support for metric disaggregation (uses the spp_cel_domain SQL CASE compiler).

Added on top of #76 (not in the original)

  • gemini-code-assist review findings, all applied: recordset subtraction for individuals; batched memberships.individual.ids (avoids N+1); _fields membership check instead of hasattr on recordsets; early return for falsy raw_value before code search; default passed directly as a SQL parameter (two sites).
  • Version bump + HISTORY entry.

Verification

…pport (from #76)

Re-lands the spp_metric_service portion of reverted PR #76. Depends on the
spp_cel_domain SQL CASE compiler (#275) — do not merge before it.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces demographic breakdown expansion and SQL column compilation support for metric disaggregation. Key changes include updating model names, refining the age group dimension to align with UNICEF/WHO buckets, automatically expanding groups to members for individual-level dimensions, and adding a to_sql_column method to compile dimensions into SQL expressions. The reviewer feedback focuses on performance and code quality optimizations, such as using recordset subtraction instead of lambda filtering, batch-fetching membership IDs to prevent N+1 queries, checking _fields on Odoo recordsets instead of using hasattr, guarding against falsy values early, and removing redundant SQL parameter wrapping.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread spp_metric_service/models/breakdown_service.py Outdated
Comment thread spp_metric_service/models/breakdown_service.py Outdated
Comment thread spp_metric_service/models/demographic_dimension.py Outdated
Comment thread spp_metric_service/models/demographic_dimension.py
Comment thread spp_metric_service/models/demographic_dimension.py
Comment thread spp_metric_service/models/demographic_dimension.py
- recordset subtraction instead of lambda filter for individuals
- batch individual ids from memberships (avoids N+1)
- check _fields membership instead of hasattr on recordsets
- early return for falsy raw_value before code search
@gonzalesedwin1123

Copy link
Copy Markdown
Member Author

gemini-code-assist disposition:

Applied (commit 778e037): recordset subtraction for individuals, batched memberships.individual.ids, _fields membership check instead of hasattr, early return for falsy raw_value. Suite: 161/0 on the integration state with #275.

Deferred: the two SQL("%s", default) wrapping comments — both forms parameterize identically with Odoo's SQL wrapper; cosmetic, and I'd rather keep the re-land diff byte-stable. Happy to fold in if reviewers prefer.

@gemini-code-assist

Copy link
Copy Markdown

Thank you for the detailed disposition. The changes you've implemented, particularly the shift to _fields checks and the batching of memberships.individual.ids, are solid improvements for performance and robustness in an Odoo environment. Deferring the cosmetic SQL wrapping is also a sensible decision to maintain diff stability. Everything looks well-aligned with the requirements.

@gonzalesedwin1123

Copy link
Copy Markdown
Member Author

Update: the two deferred SQL("%s", default) simplifications are applied (direct parameter passing). Suite 161/0 on the integration state. All gemini findings on this PR are now addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant