diff --git a/etc/db-config.yaml b/etc/db-config.yaml index ed70e302add..c1333251e6a 100644 --- a/etc/db-config.yaml +++ b/etc/db-config.yaml @@ -259,6 +259,15 @@ default_value: true public: true description: Show submission and problem statistics on the team and public pages. + - name: show_teams_on_scoreboard + type: int + default_value: 0 + public: true + description: Show teams on the scoreboard? + options: + 0: Always + 1: After login + 2: After first submission - category: Authentication description: Options related to authentication. items: diff --git a/webapp/src/Service/ScoreboardService.php b/webapp/src/Service/ScoreboardService.php index 9d0a4da2d7c..6d419f783c1 100644 --- a/webapp/src/Service/ScoreboardService.php +++ b/webapp/src/Service/ScoreboardService.php @@ -39,6 +39,10 @@ */ class ScoreboardService { + final public const SHOW_TEAM_ALWAYS = 0; + final public const SHOW_TEAM_AFTER_LOGIN = 1; + final public const SHOW_TEAM_AFTER_SUBMIT = 2; + protected EntityManagerInterface $em; protected DOMJudgeService $dj; protected ConfigurationService $config; @@ -932,8 +936,17 @@ protected function getTeams(Contest $contest, bool $jury = false, Filter $filter ->setParameter('cid', $contest->getCid()); } + $show_filter = $this->config->get('show_teams_on_scoreboard'); if (!$jury) { $queryBuilder->andWhere('tc.visible = 1'); + if ($show_filter === self::SHOW_TEAM_AFTER_LOGIN) { + $queryBuilder + ->join('t.users', 'u', Join::WITH, 'u.last_login IS NOT NULL OR u.last_api_login IS NOT NULL'); + } elseif ($show_filter === self::SHOW_TEAM_AFTER_SUBMIT) { + $queryBuilder + ->join('t.submissions', 's', Join::WITH, 's.contest = :cid') + ->setParameter('cid', $contest->getCid()); + } } if ($filter) { diff --git a/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php b/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php index f6fd73f5ec4..a756a8cb5ba 100644 --- a/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php +++ b/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php @@ -88,11 +88,12 @@ protected function setUp(): void // Default configuration values: $this->configValues = [ - 'verification_required' => false, - 'compile_penalty' => false, - 'penalty_time' => 20, - 'score_in_seconds' => false, - 'data_source' => 0, + 'verification_required' => false, + 'compile_penalty' => false, + 'penalty_time' => 20, + 'score_in_seconds' => false, + 'data_source' => 0, + 'show_teams_on_scoreboard' => 0, ]; $this->config = $this->createMock(ConfigurationService::class);