Skip to content

fix: read the contest's own problems and teams, not the 2017 tables (#106) - #107

Merged
matbrgz merged 1 commit into
masterfrom
fix/106-legacy-tables
Sep 13, 2026
Merged

matbrgz merged 1 commit into
masterfrom
fix/106-legacy-tables

Conversation

@matbrgz

@matbrgz matbrgz commented Sep 13, 2026

Copy link
Copy Markdown
Member

Fecha a #106.

Duas telas liam exercises e teams, as tabelas Helium de 2017. Um concurso criado pelo assistente escreve em problems e users e nunca encosta nelas.

O painel contradizia a si mesmo

Ele contava as duas legadas, enquanto as contagens de submissão logo abaixo vinham de runs. Em qualquer competição real isso exibia "0 problemas, 0 times, N submissões" — quatro números de destaque lado a lado, dois deles desmentindo os outros dois.

Agora os quatro são escopados a um concurso: o do próprio espectador quando ele tem um, senão a competição em andamento, e nunca o Treino Livre (#43).

Pior: a equipe não conseguia abrir esclarecimento sobre um problema

O seletor do formulário vinha de exercises, então estava sempre vazio — "Geral" era a única coisa que dava para perguntar. Agora lista os problemas do concurso por letra e nome, a listagem mostra esse rótulo em vez de Problema #7, e o problem_id enviado é conferido contra o concurso antes de ser gravado — clarifications.problem_id tem FK para problems, então id vindo de qualquer lugar não tinha o que fazer ali.

Um terceiro bug caiu no colo ao escrever o teste

O home.blade.php renderiza $submission->time . 's' na coluna "Tempo", e nada nunca selecionou um time: o painel estourava Undefined property: stdClass::$time assim que a competição tinha a primeira submissão. Nenhum teste jamais tinha carregado aquela página com uma run no banco.

Agora reporta a duração do julgamento, e existe um teste que carrega o painel com submissão julgada.

Três testes existentes afirmavam o comportamento errado

Semeavam exercises/teams e conferiam que o painel os contava, e esperavam a chave exercises na view de esclarecimentos. Passam a aferir as tabelas reais.

O SiteController::teams() já fazia isso certo — foi de lá que veio a forma da consulta.

Suíte: 797 verdes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY

…106)

Closes #106.

Two screens read `exercises` and `teams`, the Helium tables from 2017. A
contest created through the wizard writes to `problems` and `users` and
never touches them.

The dashboard counted both, while the submission counts right below came
from `runs`. On any real contest it showed "0 problems, 0 teams, N
submissions" -- four headline numbers side by side, two of them
contradicting the other two. All four are now scoped to one contest: the
viewer's own if they have one, otherwise the running competition, never
the practice contest (#43).

Worse, the clarification form's problem dropdown was filled from
`exercises`, so it was always empty and a team could only ever ask a
"Geral" clarification, never one about a problem. It now lists the
contest's problems by letter and name, the listing shows that label
instead of "Problema #7", and a posted problem_id is checked against the
contest before it is stored -- clarifications.problem_id is a foreign key
to `problems`, so an id from anywhere had no business reaching it.

A third bug fell out of writing the test. home.blade.php renders
`$submission->time . 's'` in its "Tempo" column and nothing ever selected
a `time`: the dashboard threw "Undefined property: stdClass::$time" the
moment a contest had its first submission. No test had ever loaded it with
a run in the database. It now reports the judged duration, and there is a
test that loads the dashboard with a judged submission.

Three existing tests were asserting the old behaviour -- seeding
`exercises`/`teams` and checking the dashboard counted them, and expecting
an `exercises` key in the clarification view. They assert the real tables
now.

SiteController::teams() already did this correctly, which is where the
query shape came from.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY
@matbrgz
matbrgz merged commit 74e7573 into master Sep 13, 2026
3 checks passed
@matbrgz
matbrgz deleted the fix/106-legacy-tables branch September 13, 2026 20:41
matbrgz added a commit that referenced this pull request Sep 13, 2026
…ads (#99) (#111)

Closes #99.

/backend/teams sat in the main admin sidebar and read `DB::table('teams')`,
the Helium table from 2017 -- team_id, teamName, score. The contest's
actual teams are rows in `users` with user_type='team', which is what
SubmitController, Leaderboard, Score, BocaWebcastZipBuilder and the ICPC
report all use.

After #107 removed the other two readers, the audit was unambiguous:
`exercises` has no reader or writer left anywhere, and `teams` had exactly
one consumer -- this screen, which read, wrote and deleted its own table
while nothing else ever looked at what it wrote. Not a screen that had
fallen out of date; a closed loop that was never connected to anything.

Both reference implementations model this the same way, and neither the
way this screen did:

  BOCA has one usertable and one admin/user.php; a team is a user with
  type='team'. There is no teams table and no teams screen.

  CD-MOJ's source of truth is contests/<id>/users/<login>/, one directory
  per account. It does have a "Times" screen, but read what it is:
  "Identidade de cada conta no placar: nome do time, país/bandeira, sede,
  universidade, brasão e foto" -- presentation metadata hanging off
  accounts, with the roster in a separate "Inscrições" screen.

So the menu slot is worth having eventually; what occupied it was not it.
#105 gave account editing a real home in /backend/users, and /site/teams
already lists a site's real teams.

The four legacy tables (teams, exercises, exercise_team, team_user) are
deliberately left in place. Dropping them is irreversible and I cannot
verify from here whether anything outside this repository reads that
database -- an old report, an operations script. The screen is the part
that was actively misleading, and removing it changes no data.


Claude-Session: https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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