Skip to content

Commit a76a00c

Browse files
committed
feat: add metrics services and aggregation engine
New modules: - spp_metrics_services: demographic dimensions and shared metric computation services built on CEL domain - spp_aggregation: unified aggregation engine with TTL-based caching, scope-based access control, and cron-managed cache cleanup
1 parent 5ac7496 commit a76a00c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+8793
-0
lines changed

spp_aggregation/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models

spp_aggregation/__manifest__.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
{
3+
"name": "OpenSPP Aggregation Engine",
4+
"summary": "Unified aggregation service for statistics, simulations, and GIS queries",
5+
"category": "OpenSPP",
6+
"version": "19.0.2.0.0",
7+
"sequence": 1,
8+
"author": "OpenSPP.org",
9+
"website": "https://github.com/OpenSPP/OpenSPP2",
10+
"license": "LGPL-3",
11+
"development_status": "Alpha",
12+
"maintainers": ["jeremi"],
13+
"depends": [
14+
"base",
15+
"spp_cel_domain",
16+
"spp_area",
17+
"spp_registry",
18+
"spp_security",
19+
"spp_metrics_services",
20+
],
21+
"data": [
22+
# Security
23+
"security/aggregation_security.xml",
24+
"security/ir.model.access.csv",
25+
# Data
26+
"data/cron_cache_cleanup.xml",
27+
# Views
28+
"views/aggregation_scope_views.xml",
29+
"views/aggregation_access_views.xml",
30+
"views/menu.xml",
31+
],
32+
"assets": {},
33+
"demo": [],
34+
"images": [],
35+
"application": False,
36+
"installable": True,
37+
"auto_install": False,
38+
"description": """
39+
OpenSPP Aggregation Engine
40+
==========================
41+
42+
Provides a centralized aggregation service that unifies statistics computation
43+
across simulation, GIS API, and dashboards.
44+
45+
Features
46+
--------
47+
48+
- **Unified Scopes**: Define targeting with CEL expressions, spatial polygons,
49+
administrative areas, or explicit IDs
50+
- **Multi-dimensional Breakdown**: Group by configurable demographic dimensions
51+
(gender, disability, area, age group)
52+
- **Privacy Protection**: K-anonymity with complementary suppression prevents
53+
differencing attacks
54+
- **Access Control**: Aggregate-only access for researchers (no individual records)
55+
- **Distribution Statistics**: Gini coefficient, Lorenz curve, percentiles
56+
- **Fairness Analysis**: Parity analysis across demographic groups
57+
58+
Architecture
59+
------------
60+
61+
::
62+
63+
┌─────────────────────────────────────────────────────────┐
64+
│ CONSUMERS │
65+
├─────────────┬─────────────┬─────────────┬───────────────┤
66+
│ Simulation │ GIS API │ QGIS Plugin │ Dashboards │
67+
└──────┬──────┴──────┬──────┴──────┬──────┴───────┬───────┘
68+
│ │ │ │
69+
▼ ▼ ▼ ▼
70+
┌─────────────────────────────────────────────────────────┐
71+
│ spp.aggregation.service (AbstractModel) │
72+
│ │
73+
│ compute_aggregation(scope, statistics, group_by) │
74+
└─────────────────────────────────────────────────────────┘
75+
76+
Models
77+
------
78+
79+
- ``spp.aggregation.scope``: Unified targeting scope (CEL, spatial, area)
80+
- ``spp.aggregation.access.rule``: Access control for aggregate-only users
81+
- ``spp.demographic.dimension``: Configurable breakdown dimensions
82+
83+
Services
84+
--------
85+
86+
- ``spp.aggregation.service``: Main computation entry point
87+
- ``spp.aggregation.scope.resolver``: Resolve scope to registrant IDs
88+
- ``spp.aggregation.cache``: TTL-based result caching
89+
- ``spp.metrics.distribution``: Gini, Lorenz, percentiles
90+
- ``spp.metrics.fairness``: Parity analysis
91+
- ``spp.metrics.privacy``: K-anonymity enforcement
92+
""",
93+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<odoo>
3+
<data noupdate="1">
4+
<!-- Cron job to clean up expired cache entries -->
5+
<record id="ir_cron_cache_cleanup" model="ir.cron">
6+
<field name="name">Aggregation: Cache Cleanup</field>
7+
<field name="model_id" ref="model_spp_aggregation_cache_entry"/>
8+
<field name="state">code</field>
9+
<field name="code">model.cron_cleanup_expired()</field>
10+
<field name="interval_number">1</field>
11+
<field name="interval_type">hours</field>
12+
<field name="active">True</field>
13+
</record>
14+
</data>
15+
</odoo>

spp_aggregation/models/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
3+
from . import aggregation_scope
4+
from . import aggregation_access
5+
from . import service_scope_resolver
6+
from . import service_cache
7+
from . import statistic_registry
8+
from . import service_aggregation

0 commit comments

Comments
 (0)