-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: rename analytics module ecosystem for clarity #78
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
4f4b63e
5b4e835
38ce979
78cdcc1
5bf224c
9cfc96e
6ba43a6
bf3f105
6b323ad
bc719db
99b6179
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,8 @@ | ||
| # Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
|
|
||
| from . import aggregation_scope | ||
| from . import aggregation_access | ||
| from . import analytics_scope | ||
| from . import analytics_access | ||
| from . import service_scope_resolver | ||
| from . import service_cache | ||
| from . import statistic_registry | ||
| from . import indicator_registry | ||
| from . import service_aggregation |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -6,15 +6,15 @@ | |||||
| _logger = logging.getLogger(__name__) | ||||||
|
|
||||||
|
|
||||||
| class StatisticRegistry(models.AbstractModel): | ||||||
| class IndicatorRegistry(models.AbstractModel): | ||||||
| """Registry that maps statistic names to computation strategies. | ||||||
|
|
||||||
| Replaces the fallback chain in compute_single_statistic with | ||||||
| a clean lookup-based approach. Each statistic type registers | ||||||
| how it should be computed. | ||||||
| """ | ||||||
|
|
||||||
| _name = "spp.aggregation.statistic.registry" | ||||||
| _name = "spp.analytics.indicator.registry" | ||||||
| _description = "Statistic Computation Registry" | ||||||
|
|
||||||
| @api.model | ||||||
|
|
@@ -23,7 +23,7 @@ def compute(self, stat_name, registrant_ids, context=None): | |||||
|
|
||||||
| Lookup order: | ||||||
| 1. Built-in statistics (count, gini) | ||||||
| 2. spp.statistic records (via CEL variable) | ||||||
| 2. spp.indicator records (via CEL variable) | ||||||
| 3. spp.cel.variable records (direct) | ||||||
|
|
||||||
| :param stat_name: Statistic name | ||||||
|
|
@@ -36,7 +36,7 @@ def compute(self, stat_name, registrant_ids, context=None): | |||||
| if builtin_method is not None: | ||||||
| return builtin_method(registrant_ids) | ||||||
|
|
||||||
| # Try spp.statistic (if module installed) | ||||||
| # Try spp.indicator (if module installed) | ||||||
| value = self._try_statistic_model(stat_name, registrant_ids) | ||||||
| if value is not None: | ||||||
| return value | ||||||
|
|
@@ -49,18 +49,18 @@ def compute(self, stat_name, registrant_ids, context=None): | |||||
| # Provide diagnostic information if debug logging is enabled | ||||||
| if _logger.isEnabledFor(logging.DEBUG): | ||||||
| # Check if models exist | ||||||
| has_stat_model = self.env.get("spp.statistic") is not None | ||||||
| has_stat_model = self.env.get("spp.indicator") is not None | ||||||
| has_var_model = self.env.get("spp.cel.variable") is not None | ||||||
|
|
||||||
| stat_count = 0 | ||||||
| var_count = 0 | ||||||
| if has_stat_model: | ||||||
| stat_count = self.env["spp.statistic"].sudo().search_count([]) # nosemgrep: odoo-sudo-without-context | ||||||
| stat_count = self.env["spp.indicator"].sudo().search_count([]) # nosemgrep: odoo-sudo-without-context | ||||||
| if has_var_model: | ||||||
| var_count = self.env["spp.cel.variable"].sudo().search_count([]) # nosemgrep: odoo-sudo-without-context | ||||||
|
|
||||||
| _logger.debug( | ||||||
| "Statistic lookup failed for '%s'. Available: %d spp.statistic, %d spp.cel.variable", | ||||||
| "Statistic lookup failed for '%s'. Available: %d spp.indicator, %d spp.cel.variable", | ||||||
| stat_name, | ||||||
| stat_count, | ||||||
| var_count, | ||||||
|
|
@@ -82,8 +82,8 @@ def list_available(self): | |||||
| for name, info in self._BUILTINS.items(): | ||||||
| available.append({"name": name, "label": info["label"], "source": "builtin"}) | ||||||
|
|
||||||
| # From spp.statistic | ||||||
| stat_model = self.env.get("spp.statistic") | ||||||
| # From spp.indicator | ||||||
| stat_model = self.env.get("spp.indicator") | ||||||
| if stat_model: | ||||||
| for stat in stat_model.sudo().search([("active", "=", True)]): # nosemgrep: odoo-sudo-without-context | ||||||
| available.append({"name": stat.name, "label": stat.label, "source": "statistic"}) | ||||||
|
|
@@ -145,13 +145,13 @@ def _compute_gini(self, registrant_ids): | |||||
|
|
||||||
| @api.model | ||||||
| def _try_statistic_model(self, stat_name, registrant_ids): | ||||||
|
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 method name
Suggested change
|
||||||
| """Try computing via spp.statistic record. | ||||||
| """Try computing via spp.indicator record. | ||||||
|
|
||||||
| :param stat_name: Statistic name | ||||||
| :param registrant_ids: List of partner IDs | ||||||
| :returns: Computed value or None | ||||||
| """ | ||||||
| stat_model = self.env.get("spp.statistic") | ||||||
| stat_model = self.env.get("spp.indicator") | ||||||
| if stat_model is None: | ||||||
| return None | ||||||
| stat = stat_model.sudo().search([("name", "=", stat_name)], limit=1) # nosemgrep: odoo-sudo-without-context | ||||||
|
|
||||||
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
sourceis hardcoded as'statistic'. To align with the refactoring ofspp.statistictospp.indicator, this should be updated to'indicator'for consistency.