Skip to content

Commit c808804

Browse files
Fix scoreboard filter for non scoring categories
Fixes #2937
1 parent 671d0bf commit c808804

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

webapp/src/Service/ScoreboardService.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ protected function getTeamsInOrder(Contest $contest, bool $jury = false, ?Filter
958958
{
959959
$queryBuilder = $this->em->createQueryBuilder()
960960
->from(Team::class, 't', 't.teamid')
961+
// Join on categories twice: once to determine the sort order (tc) and once to get all categories the team belongs to (tcc)
961962
->innerJoin('t.categories', 'tc', Join::WITH, 'BIT_AND(tc.types, :scoring) = :scoring')
962963
->innerJoin('t.categories', 'tcc')
963964
->leftJoin(RankCache::class, 'r', Join::WITH, 'r.team = t AND r.contest = :rcid')
@@ -998,9 +999,14 @@ protected function getTeamsInOrder(Contest $contest, bool $jury = false, ?Filter
998999
}
9991000

10001001
if ($filter->categories) {
1002+
// Use a new join, since we need both the other two category joins for other logic already
10011003
$queryBuilder
1002-
->andWhere('tc.categoryid IN (:categories)')
1004+
->innerJoin('t.categories', 'tccc')
1005+
->andWhere('tccc.categoryid IN (:categories)')
10031006
->setParameter('categories', $filter->categories);
1007+
if (!$jury) {
1008+
$queryBuilder->andWhere('tccc.visible = 1');
1009+
}
10041010
}
10051011

10061012
if ($filter->countries) {

0 commit comments

Comments
 (0)