-
Notifications
You must be signed in to change notification settings - Fork 1
perf: add canary patterns to skip statistics during bulk operations #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 19.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,8 @@ def _compute_total_entitlements_count(self): | |
| @api.depends("program_membership_ids") | ||
| def _compute_program_membership_count(self): | ||
| """Batch-efficient program membership count using read_group.""" | ||
| if self.env.context.get("skip_registrant_statistics"): | ||
| return | ||
|
Comment on lines
+46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Please consider adding a |
||
| if not self: | ||
| return | ||
|
|
||
|
|
@@ -66,6 +68,8 @@ def _compute_program_membership_count(self): | |
| @api.depends("entitlement_ids") | ||
| def _compute_entitlements_count(self): | ||
| """Batch-efficient entitlements count using _read_group.""" | ||
| if self.env.context.get("skip_registrant_statistics"): | ||
| return | ||
| if not self: | ||
| return | ||
|
|
||
|
|
@@ -89,6 +93,8 @@ def _compute_entitlements_count(self): | |
| @api.depends("cycle_ids") | ||
| def _compute_cycle_count(self): | ||
| """Batch-efficient cycle membership count using _read_group.""" | ||
| if self.env.context.get("skip_registrant_statistics"): | ||
| return | ||
| if not self: | ||
| return | ||
|
|
||
|
|
@@ -112,6 +118,8 @@ def _compute_cycle_count(self): | |
| @api.depends("inkind_entitlement_ids") | ||
| def _compute_inkind_entitlements_count(self): | ||
| """Batch-efficient in-kind entitlements count using _read_group.""" | ||
| if self.env.context.get("skip_registrant_statistics"): | ||
| return | ||
| if not self: | ||
| return | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
refresh_statisticsmethod appears to be redundant in its current implementation. The fields it attempts to refresh (members_count,entitlements_count, andtotal_entitlements_count) are allstore=Falseand do not implement the "canary" skip logic found in other models.Since these fields are computed on-demand and the underlying relation caches are correctly invalidated in the managers (e.g., via
cycle.invalidate_recordset(['cycle_membership_ids'])), they will naturally reflect the correct values upon the next access without an explicit refresh call. If the intention was to optimize these fields for bulk operations, they should be madestore=Trueand implement the skip logic, similar tohas_membersinspp.program.