TorbatYar/backend/services/experience/app/policies/analytics.py
Mortezakoohjani 203671a7bf feat(experience): ship Experience Platform phases 11.0-11.10
Add the experience service with sites through analytics/AI hooks, migrations through 0011, and phase docs/manifests marking the track complete.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 11:43:10 +03:30

26 lines
847 B
Python

"""Lifecycle policies for Phase 11.10 analytics aggregates."""
from app.models.types import AnalyticsReportStatus as R, AnalyticsSnapshotStatus as S
from app.validators.integrations import ensure_transition
_TRANSITIONS = {
R: {
R.DRAFT: frozenset({R.ACTIVE, R.ARCHIVED}),
R.ACTIVE: frozenset({R.ARCHIVED}),
R.ARCHIVED: frozenset(),
},
S: {
S.ACTIVE: frozenset({S.ARCHIVED}),
S.ARCHIVED: frozenset(),
},
}
class AnalyticsReportDefinitionPolicy:
def assert_status_change(self, *, current, target):
ensure_transition(current, target, _TRANSITIONS[R], "analytics_report_definition")
class AnalyticsSnapshotPolicy:
def assert_status_change(self, *, current, target):
ensure_transition(current, target, _TRANSITIONS[S], "analytics_snapshot")