Skip to content

Show LOC on concluded rankings#251

Merged
msaroufim merged 1 commit into
mainfrom
show-ranking-loc-tested
Jul 5, 2026
Merged

Show LOC on concluded rankings#251
msaroufim merged 1 commit into
mainfrom
show-ranking-loc-tested

Conversation

@msaroufim

Copy link
Copy Markdown
Member

Summary

  • Reintroduce LOC on the main ranking rows for concluded competitions after the Revert "Show LOC on concluded rankings" #250 revert.
  • Compute leaderboard line_count after the main ranking query using Python decoding that supports both text and bytea code storage.
  • Keep LOC fail-closed: if LOC lookup/decoding fails, the leaderboard response still returns without LOC.
  • Keep the simplified surface from Show LOC on concluded rankings #249: no code-drawer LOC plumbing, and concluded leaderboards are no longer blocked by the old 598 special case.

Root Cause

  • Production kernelbot migrations store leaderboard.code_files.code as BYTEA.
  • The reverted implementation tried to run regexp_replace(cf.code, ...) in SQL, which works on the seed TEXT schema but fails on production-style BYTEA with function regexp_replace(bytea, unknown, unknown) does not exist.

Validation

  • Created local kernelboard_loc_test from tests/data.sql and verified /api/leaderboard/339 and /api/leaderboard/340 return 200 with LOC.
  • Created local kernelboard_loc_bytea_test from tests/data.sql, applied the kernelbot bytea migration shape to leaderboard.code_files.code, reproduced the old 500, then verified the patched API returns 200 with LOC.
  • Ran local Flask server on 127.0.0.1:5055 against the bytea DB and curled /api/leaderboard/339: 200, loc_count=12, sample [56, 56, 56, 56, 56].
  • .venv/bin/ruff check kernelboard/api/leaderboard.py kernelboard/api/submission.py tests/api/test_leaderboard_api.py tests/api/test_submission_api.py
  • npm run lint
  • npm run build
  • git diff --check

Notes

  • Full pytest was not run because the repo pytest fixture starts Docker Postgres/Redis and Docker is not running in this local environment. The endpoint was tested against local Postgres directly, including a production-like bytea schema.

@msaroufim msaroufim merged commit 6e74a31 into main Jul 5, 2026
1 check 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