Skip to content

feat(report): ICPC standings export (#89) - #92

Merged
matbrgz merged 1 commit into
masterfrom
feat/89-icpc-report
Sep 13, 2026
Merged

matbrgz merged 1 commit into
masterfrom
feat/89-icpc-report

Conversation

@matbrgz

@matbrgz matbrgz commented Sep 13, 2026

Copy link
Copy Markdown
Member

Fecha a #89.

users.icpc_id existe desde 2025_11_25_000007 e nada o usava — nenhuma referência no código, e nenhum formulário que o preenchesse. O BOCA produz o arquivo para o qual ele existe em src/admin/report/icpc.php: uma linha CSV por equipe, na ordem da classificação final.

usericpcid, colocação, resolvidos, tempo total, primeiro AC

Não é a exportação de webcast da #44. Aquela transmite o placar ao vivo para o telão; esta é o registro do que aconteceu, e o consumidor é uma pessoa prestando contas para a regional.

Três superfícies

IcpcReportBuilder a lógica, lendo Leaderboard::getScoreboard() — a mesma fonte do placar público, incluindo a correção de sinal do getContestTime() da #76, sem a qual todo tempo aqui sairia negativo
GET /api/frontend/contests/{contest}/icpc-report navegador: sessão admin, text/csv como anexo, no-store
php artisan contest:icpc-report {id} [--output=] o host da competição às 2h da manhã por ssh, que é onde isso de fato acontece

Equipes sem icpc_id

Reportadas, não barradas. O BOCA emite o relatório com a coluna em branco, e o organizador pode legitimamente estar exportando antes de preencher os ids. O comando lista os nomes; o endpoint conta no header X-Icpc-Teams-Missing-Id. Dos dois jeitos você descobre antes de mandar o arquivo, não depois.

Treino Livre

Recusado pelos dois caminhos (404 no endpoint, falha no comando). Não é evento, não tem classificação, e não pode ser alcançável por uma exportação com formato de evento.

Preenchimento do campo

icpc_id passa a ser preenchível no formulário de usuário do backend — o único lugar onde uma conta de competição é criada fora da API de contas geridas. Adicionar lá também mudaria o contrato de frontend da #47, então deixei quieto; vale uma nota na #47 se for desejado.

Testes

11 novos: layout das cinco colunas na ordem da classificação, primeiro AC como o mínimo entre os resolvidos (não o último, não o total), 0 para quem não resolveu nada, vírgula no id que não desloca coluna, listagem de quem está sem id, 401/403/404, e os três modos do comando. Suíte: 736 verdes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY

Closes #89.

`users.icpc_id` has existed since 2025_11_25_000007 and nothing used it --
not one reference in the codebase, and no form that could set it. BOCA
produces the file it exists for in src/admin/report/icpc.php: one CSV line
per team, in final standings order,

    usericpcid, placement, solved, total time, first solve

This is not the webcast export of #44. That one streams a live scoreboard
to a ceremony display; this is the record of what happened, and its
consumer is a person filing results with a regional.

Three surfaces, because filing results happens in more than one way:

- `IcpcReportBuilder` holds the logic, reading Leaderboard::getScoreboard()
  -- the same source the public scoreboard uses, including #76's
  getContestTime() sign fix, without which every time here would be
  negative.
- `GET /api/frontend/contests/{contest}/icpc-report` for the browser:
  admin session, text/csv attachment, no-store.
- `php artisan contest:icpc-report {contest} [--output=]` for the contest
  host at 2am over ssh, which is where this usually actually happens.

Teams still missing an icpc_id are reported rather than enforced: BOCA
files the report with the column blank, and an organiser may well be
exporting before the ids are in. The command names them, the endpoint
counts them in X-Icpc-Teams-Missing-Id. Either way you learn it before
sending the file, not after.

The practice contest (#43) is refused by both: it is not an event and has
no standings, and it must not be reachable through an event-shaped export.

`icpc_id` is now settable on the backend user form, which is the only
place a contest account is created outside the specced managed-accounts
API. Adding it there too would change #47's frontend contract, so that is
left alone.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Pvf2R8xtgbWQm1wRvjBqQY
@matbrgz
matbrgz merged commit 481564d into master Sep 13, 2026
3 checks passed
@matbrgz
matbrgz deleted the feat/89-icpc-report branch September 13, 2026 18:55
matbrgz added a commit that referenced this pull request Sep 13, 2026
…ted (#100) (#105)

Closes #100.

UserController had index(), store() and destroy() and nothing in between.
Any mistake in a registration could only be fixed by deleting the account
-- which cascades to its runs, scores, tasks and logs, with no undo. Name,
email, username, user_type, site, is_enabled and icpc_id were all
uncorrectable once saved.

The last one was concrete: #92 added icpc_id to the create form, so an
account that already existed had no way to receive one, and that is the
exact column contest:icpc-report needs filled on every team. The command
lists who is missing it precisely so an organiser can fill them in, and
there was nowhere to do it.

Editing keeps the row, so everything pointing at it survives. A blank
password means "leave it alone" rather than "set an empty password", and
the contest follows the chosen site exactly as it does on create.

Two guards, on both edit and delete, because there is no second screen to
undo either from:

  - You cannot disable or delete your own account.
  - The last admin cannot be demoted or deleted. destroy() had no guard at
    all before this: deleting the only admin was one confirm dialog away.

Also makes icpc_id fillable on the User model. It has existed since
2025_11_25_000007 and was never in $fillable, so an Eloquent update
dropped it silently -- the create path writes through the query builder,
which is why #92 worked and this did not until now.

Thirteen tests, including the two mistakes that would otherwise pass
review: saving a user without changing their username must not collide
with their own record, and another account's username must still be
refused.


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