Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to hide nonloggedin/nonsubmitted teams on the scoreboard #2134

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions etc/db-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,15 @@
default_value: false
public: true
description: Show canonical compiler and runner version on the team 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:
Expand Down
13 changes: 13 additions & 0 deletions webapp/src/Service/ScoreboardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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;

public function __construct(
protected readonly EntityManagerInterface $em,
protected readonly DOMJudgeService $dj,
Expand Down Expand Up @@ -944,8 +948,17 @@
->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());
}

Check failure on line 961 in webapp/src/Service/ScoreboardService.php

View workflow job for this annotation

GitHub Actions / phpcs

Line indented incorrectly; expected 12 spaces, found 16

Check failure on line 961 in webapp/src/Service/ScoreboardService.php

View workflow job for this annotation

GitHub Actions / phpcs

Closing brace indented incorrectly; expected 12 spaces, found 16
}

if ($filter) {
Expand Down
11 changes: 6 additions & 5 deletions webapp/tests/Unit/Integration/ScoreboardIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +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,
'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);
Expand Down
Loading