Skip to content

About

Statistics engine and report generator for tracking mapping participation metrics in Workspaces and OSM

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Mapping Momentum

Statistics engine and report generator for tracking mapping participation in TDEI Workspaces.

Requirements

  • Python 3.14 and uv
  • A TDEI account with access to the target workspaces
  • GitHub CLI (gh) authenticated to the repository for Pages promotion

The event and capture commands prompt for TDEI credentials, or read username/password pairs from MM_TDEI_USERNAME_<ENV> and MM_TDEI_PASSWORD_<ENV> for PROD, STAGE, or DEV. Set both variables or neither; use a secret store and never put credentials in source files, command arguments, or logs.

Setup

From the repository root, install the locked development tools, Playwright Chromium, and the pinned axe-core asset:

python utilities/initial_setup.py

Activate the virtual environment for subsequent commands:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
& .\.venv\Scripts\Activate.ps1

Generate and publish

Run the following from the repository root with the virtual environment active. Full reports contain contributor identities; keep them local and publish only the reviewed anonymized snapshot.

1. Run local checks

python -m pytest tests/unit
python -m ruff check .

2. Ensure quest-definition caches exist

Each published Workspace event needs a local quest-definition.json. This loop skips templates, unpublished events, and existing caches; rerun capture-quests for a specific event when its cache needs refreshing.

$EventConfigs = Get-ChildItem configs\events -Recurse -Filter event.json |
    Where-Object { $_.DirectoryName -notmatch '(^|[\\/])template([\\/]|$)' }
foreach ($Config in $EventConfigs) {
    $Event = Get-Content $Config.FullName -Raw | ConvertFrom-Json
    if ($Event.publish -eq $false) { continue }
    $Cache = Join-Path $Config.DirectoryName "quest-definition.json"
    if (-not (Test-Path $Cache)) {
        mapping-momentum capture-quests --config $Config.FullName
        if ($LASTEXITCODE -ne 0) { throw "Quest capture failed for $($Config.FullName)" }
    }
}

An event config can cache one unique quest-definition URL; put activities with different URLs in separate event configs.

3. Generate all configured reports

python utilities/generate_all.py

The generator fetches current Workspace data and writes full and anonymized event reports, quest-answer logs, and configured aggregates under local-output/v<project-version>/. It uses saved TDEI credentials or prompts. After an interrupted run, use python utilities/generate_all.py --resume to reuse completed full reports and logs.

4. Prepare and check the beta snapshot

Prepare prints the full beta commit SHA. Use that exact SHA for the check and approval:

mapping-momentum publish prepare
$BetaSha = "PASTE_FULL_BETA_SHA_HERE"
mapping-momentum publish check --sha $BetaSha

The check writes screenshots and review records under local-output/v<project-version>/report-checks/.

5. Review and approve the public beta

Inspect the screenshots, collage, visible report content, and embedded HTML data for identifying or sensitive information. Confirm supplied images are approved for public use; a TDEI Workspace ID alone does not establish that its contents are public.

mapping-momentum publish approve --sha $BetaSha

Approval requires this exact confirmation and immediately pushes the beta commit publicly:

Yes, I checked these and confirmed there is nothing that needs redaction or anonymization.

The beta ref has no separate Pages site.

6. Promote the reviewed SHA to Pages

One-time GitHub setup: require the source-quality check on main; create the pages-promotion environment restricted to main; set PAGES_PUBLIC_URL; and add a repository-scoped fine-grained PAT with Contents read/write as MAPPING_MOMENTUM_PUBLISH_PAT. Pages must deploy from the root of the stable branch.

Dispatch promotion with the same reviewed SHA and wait for the workflow to verify the served site:

gh auth status
gh workflow run promote-pages.yml --ref main --field beta_sha="$BetaSha"

For the first publication, the workflow creates stable; if Pages verification fails because the branch is not configured as the Pages source yet, configure Pages to use stable and rerun the dispatch with the same SHA.

Useful commands and configuration

For one event, capture its quest definition if needed, then generate all its activities:

mapping-momentum capture-quests --config configs/events/<event-id>
mapping-momentum event --config configs/events/<event-id>/event.json --output-dir local-output --quest-answer-log

--anonymize anonymizes event or aggregate output. --render-from-stats <stats.json> rerenders an event without fetching live data. --dry-run prints event stats without writing reports.

Aggregates are defined in configs/aggregates/<id>.json with an id, title, and ordered reports list of { "event_id", "activity_id" } entries. Add reports explicitly; aggregate from full, non-anonymized stats so contributors can be matched before anonymizing the combined report.

Set "publish": false to exclude an event from generation, aggregates, and the public index. Set "redact_note_content": true to hide note text in anonymized event and aggregate reports; full reports retain it. Optional report content includes pictures, quotes, slideshow_url, and video_url, at event or report scope.

Reports are self-contained with respect to event data, but maps and remote media require internet access.

About

Statistics engine and report generator for tracking mapping participation metrics in Workspaces and OSM

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Used by

Contributors

Languages