Skip to content

Commit 04ab1c8

Browse files
committed
Fix scoreboard update after rejudging.
Previous buggy flow was something like: - fetch all submissions that for this team/contest/problem combination - that are valid - and have a valid judging The idea of https://github.com/DOMjudge/domjudge/blob/95df1de7bce91f43600cfcb8760ea85762936614/webapp/src/Service/ScoreboardService.php#L240 was that this would filter the OneToMany collection down to only valid judgings. This is also what happens on the database side. However, on the doctrine side, the entity manager keeps a cache, and if the submission is already in the cache with the full collection of valid and invalid judgings, it will only merged with new data from the database query, no data (i.e. no judgings) will magically disappear. In order to fix this, we explicitly filter on the PHP side. An alternative would be to add a new `OneToMany` mapping with a `where` on it and use that. Fixes #2883
1 parent 1e527a1 commit 04ab1c8

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

webapp/src/Entity/Submission.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,16 @@ public function getJudgings(): Collection
359359
return $this->judgings;
360360
}
361361

362+
public function getValidJudging(): ?Judging
363+
{
364+
foreach ($this->judgings as $j) {
365+
if ($j->getValid()) {
366+
return $j;
367+
}
368+
}
369+
return null;
370+
}
371+
362372
public function setLanguage(?Language $language = null): Submission
363373
{
364374
$this->language = $language;
@@ -537,6 +547,16 @@ public function getExternalJudgements(): Collection
537547
return $this->external_judgements;
538548
}
539549

550+
public function getValidExternalJudgement(): ?ExternalJudgement
551+
{
552+
foreach ($this->external_judgements as $ej) {
553+
if ($ej->getValid()) {
554+
return $ej;
555+
}
556+
}
557+
return null;
558+
}
559+
540560
public function setFileForApi(?FileWithName $fileForApi = null): Submission
541561
{
542562
$this->fileForApi = $fileForApi;

webapp/src/Service/ScoreboardService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ public function calculateScoreRow(
262262
foreach ($submissions as $submission) {
263263
/** @var Judging|ExternalJudgement|null $judging */
264264
if ($useExternalJudgements) {
265-
$judging = $submission->getExternalJudgements()->first() ?: null;
265+
$judging = $submission->getValidExternalJudgement();
266266
} else {
267-
$judging = $submission->getJudgings()->first() ?: null;
267+
$judging = $submission->getValidJudging();
268268
}
269269

270270
// three things will happen in the loop in this order:

0 commit comments

Comments
 (0)