Skip to content

DEV: add participant regions to program analytics - #723

Merged
TThanos3000 merged 1 commit into
devfrom
feature/dev-program-participant-regions
Sep 3, 2026
Merged

DEV: add participant regions to program analytics#723
TThanos3000 merged 1 commit into
devfrom
feature/dev-program-participant-regions

Conversation

@TThanos3000

@TThanos3000 TThanos3000 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Audit result

  • User.city remains the only persisted user geography field used by this change.
  • The existing manager overview exposes project regions only; participant-region aggregation was absent.
  • Participant regions therefore require this separate backend contract before the Angular UI can consume them.

Summary

  • adds summary.participant_regions to GET /programs/<program_id>/manager-overview/ using the existing regions response shape;
  • uses the same authoritative participant population as summary.participants.total: unique non-null PartnerProgramUserProfile.user_id values for the selected program;
  • excludes null, empty and whitespace-only User.city values;
  • trims surrounding whitespace, groups equal resulting strings and sorts by count descending, then name;
  • preserves legacy values exactly as separate analytics entries: no lowercasing, title-casing, typo correction, city-to-region mapping or data migration.

Contract

{
  "summary": {
    "regions": {
      "total": 1,
      "items": [{"name": "Москва", "count": 2}]
    },
    "participant_regions": {
      "total": 2,
      "items": [
        {"name": "Москва", "count": 2},
        {"name": "Набережные Челны", "count": 1}
      ]
    }
  }
}

summary.regions keeps its existing project-region semantics. summary.participant_regions contains user geography from User.city.

Verification

  • targeted manager analytics tests: 17/17 passed;
  • full local backend suite: 581/581 passed (1 skipped);
  • GitHub Backend PostgreSQL CI: passed, including an empty-database migration run and the full backend suite;
  • GitHub standard CI tests: passed;
  • GitHub CI lint: passed;
  • Black on changed Python files: passed;
  • flake8 on changed Python files: passed;
  • repository-wide flake8 still reports pre-existing violations in unrelated, unchanged files;
  • python manage.py check: passed;
  • python manage.py check --tag models: passed;
  • python manage.py makemigrations --check --dry-run: no changes detected;
  • git diff --check: passed.

Scope

  • no models or migrations;
  • no changes to User.city data;
  • no Angular or React changes;
  • no workflow, Docker or deploy changes.

Draft only. Do not merge or deploy automatically.

@TThanos3000
TThanos3000 marked this pull request as ready for review September 3, 2026 13:40
@TThanos3000
TThanos3000 merged commit 95009d4 into dev Sep 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant