Skip to content

Pantheon community race leaderboard snapshot (API) - #150

Merged
owens1127 merged 1 commit into
mainfrom
fix-pantheon-community-race-snapshot
Jun 30, 2026
Merged

Pantheon community race leaderboard snapshot (API)#150
owens1127 merged 1 commit into
mainfrom
fix-pantheon-community-race-snapshot

Conversation

@owens1127

Copy link
Copy Markdown
Contributor

Summary

  • Read the pantheon community race leaderboard from pantheon_custom_race_snapshot instead of the live team_pantheon_custom_race_leaderboard materialized view.
  • Falls back to the legacy MV when the snapshot table is missing (42P01), so this can deploy safely before or after the DB migration.
  • Companion: Raid-Hub/Services (migration 012/013 — snapshot table + MV drop).

Rollout (no downtime)

Apply in this order. Each step is safe to pause between.

Step 1 — Prod SQL: create snapshot (before any deploy)

Run the contents of RaidHub-Services/infrastructure/postgres/migrations/012_pantheon_custom_race_snapshot.sql on prod.

  • Creates leaderboard.pantheon_custom_race_snapshot and seeds 110 frozen rows.
  • Does not drop the MV. Current prod API keeps working unchanged.

Dry-run after apply:

SELECT COUNT(*) FROM leaderboard.pantheon_custom_race_snapshot; -- expect 110
SELECT COUNT(*) FROM leaderboard.team_pantheon_custom_race_leaderboard; -- still 110

Step 2 — Deploy this API PR

  • API reads snapshot first; MV remains as fallback.
  • Leaderboard immediately serves frozen standings once step 1 is applied.
  • If step 1 is not applied yet, API continues using the MV (no breakage).

Smoke test:

curl -s "https://api.raidhub.io/leaderboard/team/custom/pantheon-community-race?page=1&count=5" -H "X-API-KEY: ..."

Step 3 — Prod SQL: drop legacy MV

Run RaidHub-Services/infrastructure/postgres/migrations/013_drop_pantheon_custom_race_leaderboard.sql:

DROP MATERIALIZED VIEW IF EXISTS leaderboard.team_pantheon_custom_race_leaderboard;

Safe once step 2 is deployed — API no longer depends on the MV.

Step 4 — Deploy Services PR

  • Cheat detection joins pantheon_custom_race_snapshot instead of the MV.
  • Removes the 3-minute pantheon MV cron entry.
  • Hermes restart optional (cheat-detection join only affects blacklist cascade scope).

Step 5 — Prod SQL: blacklist cleanup

Dry-run:

SELECT COUNT(*) FROM flagging.blacklist_instance bi
WHERE bi.report_source = 'Manual'
  AND bi.instance_id NOT IN (SELECT instance_id FROM leaderboard.pantheon_custom_race_snapshot)
  AND bi.reason NOT ILIKE '%cheat%'
  AND bi.reason NOT ILIKE '%cheater%'
  AND EXISTS (
    SELECT 1 FROM core.instance i
    JOIN definitions.activity_version av ON av.hash = i.hash
    WHERE i.instance_id = bi.instance_id
      AND av.version_id = 134
      AND i.date_completed >= '2026-06-13 17:00:00+00'::timestamptz
      AND i.date_completed < '2026-06-15 17:00:00+00'::timestamptz
  );
-- expect ~52

Apply:

BEGIN;
DELETE FROM flagging.blacklist_instance bi
WHERE bi.report_source = 'Manual'
  AND bi.instance_id NOT IN (SELECT instance_id FROM leaderboard.pantheon_custom_race_snapshot)
  AND bi.reason NOT ILIKE '%cheat%'
  AND bi.reason NOT ILIKE '%cheater%'
  AND EXISTS (
    SELECT 1 FROM core.instance i
    JOIN definitions.activity_version av ON av.hash = i.hash
    WHERE i.instance_id = bi.instance_id
      AND av.version_id = 134
      AND i.date_completed >= '2026-06-13 17:00:00+00'::timestamptz
      AND i.date_completed < '2026-06-15 17:00:00+00'::timestamptz
  );
COMMIT;

Removes LB-only manual blacklists for race-window instances not on the frozen standings. Cheat-marked manual blacklists are kept.

Test plan

  • bun run typecheck
  • bun test src/routes/leaderboard/team/custom.test.ts
  • After step 1+2 on prod: spot-check /leaderboard/team/custom/pantheon-community-race and a known finisher profile PGCR rank badge

Made with Cursor

Falls back to the legacy materialized view when the snapshot table is not deployed yet, enabling a phased rollout with no API downtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
@barecheck

barecheck Bot commented Jun 30, 2026

Copy link
Copy Markdown

Barecheck - Code coverage report

Total: 91.65%

Your code coverage diff: 0.13% ▴

Uncovered files and lines
FileLines
src/services/instance/instance.ts190, 226-227, 244-247
src/services/leaderboard/team/custom.ts48, 122-128

@owens1127
owens1127 merged commit c2c57c7 into main Jun 30, 2026
7 checks passed
@owens1127
owens1127 deleted the fix-pantheon-community-race-snapshot branch June 30, 2026 12:33
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