From 119859e30bbd1614b6157e514979a8155f7b61fa Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Fri, 1 Sep 2023 08:24:22 +0200 Subject: [PATCH] [Hide->Show] Implement Tobi his feedback --- etc/db-config.yaml | 10 +++++----- webapp/src/Service/ScoreboardService.php | 12 ++++++------ .../Unit/Integration/ScoreboardIntegrationTest.php | 12 ++++++------ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/etc/db-config.yaml b/etc/db-config.yaml index 57caae14024..f74df89c527 100644 --- a/etc/db-config.yaml +++ b/etc/db-config.yaml @@ -269,15 +269,15 @@ default_value: false public: true description: Show canonical compiler and runner version on the team pages. - - name: hide_teams_scoreboard_condition + - name: show_teams_on_scoreboard type: int default_value: 0 public: true - description: Hide teams on the scoreboard? + description: Show teams on the scoreboard? options: - 0: never - 1: when never logged in - 2: when didn't submit + 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 bb0b5e30bf4..11bb0b74325 100644 --- a/webapp/src/Service/ScoreboardService.php +++ b/webapp/src/Service/ScoreboardService.php @@ -32,9 +32,9 @@ class ScoreboardService { - final public const HIDE_TEAM_NEVER = 0; - final public const HIDE_TEAM_NO_LOGIN = 1; - final public const HIDE_TEAM_NO_SUBMIT = 2; + final public const SHOW_TEAM_ALWAYS = 0; + final public const SHOW_TEAM_AFTER_LOGIN = 1; + final public const SHOW_TEAM_AFTER_SUBMIT = 2; public function __construct( protected readonly EntityManagerInterface $em, @@ -948,13 +948,13 @@ protected function getTeams(Contest $contest, bool $jury = false, Filter $filter ->setParameter('cid', $contest->getCid()); } - $hide_filter = $this->config->get('hide_teams_scoreboard_condition'); + $show_filter = $this->config->get('show_teams_scoreboard'); if (!$jury) { $queryBuilder->andWhere('tc.visible = 1'); - if ($hide_filter === self::HIDE_TEAM_NO_LOGIN) { + if ($show_filter === self::SHOW_TEAM_AFTER_LOGIN) { $queryBuilder ->join('t.users', 'u', Join::WITH, 'u.last_login IS NOT NULL'); - } elseif ($hide_filter === self::HIDE_TEAM_NO_SUBMIT) { + } elseif ($show_filter === self::SHOW_TEAM_AFTER_SUBMIT) { $queryBuilder ->join('t.submissions', 's', Join::WITH, 's.contest = :cid') ->setParameter('cid', $contest->getCid()); diff --git a/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php b/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php index 7692ded0990..5be72912cb6 100644 --- a/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php +++ b/webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php @@ -65,12 +65,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, - 'hide_teams_scoreboard_condition' => 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);