Skip to content

refactor(core): split analytics reads into a reads package - #996

Open
zaira-bibi wants to merge 1 commit into
zaira/be/analytics-event-catalogfrom
zaira/be/analytics-reads-module
Open

zaira-bibi wants to merge 1 commit into
zaira/be/analytics-event-catalogfrom
zaira/be/analytics-reads-module

Conversation

@zaira-bibi

Copy link
Copy Markdown
Contributor

What

Analytics read code was spread over reads.py, a schemas/reads.py that mixed models and enums, and a
top-level enums.py, and its bucket SQL was private even though Explore needs it. This moves it into a
reads package of small, single-purpose files, with no behaviour change.

Changes

  • refactor(core): sparkth/core/analytics/reads/ replaces reads.py, schemas/reads.py and enums.py:
    • buckets.py: the PostgreSQL and SQLite bucket SQL and the day-range conditions, now public
      (PG_BUCKET, SQLITE_BUCKET, in_days)
    • rollups.py: read_rollup and its SQL-identifier checks
    • queries.py: get_logins, the core Overview figures and summarize
    • schemas.py: RangeQuery, LoginsPoint, SummaryCount
    • enums.py: Bucket
  • refactor(core): the event catalog becomes a package, with its models in catalog/schemas.py and
    FieldKind in catalog/enums.py
  • refactor(core): schemas/ now holds only the event schemas
  • sparkth.lib.analytics exports the same names, so plugins and routes are unchanged
  • chore: the es/fr catalogs point the Overview figure labels at their new file

How to Test

  1. uv run pytest -q: the whole suite passes unchanged.
  2. make test.frontend.api: the OpenAPI schema and generated client are unchanged.
  3. Open Analytics: Overview, Logins and Course authoring show the same figures as before.

Environment Variables

Notes

  • Stacked on the event catalog PR; the Explore query PR rebases onto this one.
  • No migrations, env vars or dependency changes.

This description was written with the assistance of an LLM (Claude).

🤖 Generated with Claude Code

@zaira-bibi
zaira-bibi added this pull request to stack #997 October 26, 2026 07:05
Reads code was spread over reads.py, a mixed schemas/reads.py and a
top-level enums.py, and its bucket SQL was private though Explore needs
it. The reads package splits it into buckets, rollups, queries, schemas
and enums with the bucket helpers public, and the catalog's models move
next to the catalog. The sparkth.lib.analytics surface is unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zaira-bibi
zaira-bibi force-pushed the zaira/be/analytics-reads-module branch from 822229c to 00f435c Compare October 26, 2026 07:07
@zaira-bibi zaira-bibi self-assigned this Oct 26, 2026
@zaira-bibi zaira-bibi added the refactoring Changes to the codebase that do not add any feature. label Oct 26, 2026

This branch has not been deployed

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

Labels

refactoring Changes to the codebase that do not add any feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant