Skip to content

Commit

Permalink
Add option to hide nonloggedin/nonsubmitted teams on the scoreboard (#…
Browse files Browse the repository at this point in the history
…2134)

* Add option to hide nonloggedin/nonsubmitted teams on the scoreboard

Done as a config option for the following 2 cases:
- Normally you want a team which has logged on on the scoreboard
- In case of the autologin tool of GEHACK/Nicky the user would also
login without interaction of the actual team

* Allow API logon as the submit client uses it

Alternative would be to UNION over teams which submitted and teams which
did a GUI logon but that is more expensive.
  • Loading branch information
vmcj authored Sep 3, 2023
1 parent 078f1c7 commit f989426
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
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 @@ 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) {
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

0 comments on commit f989426

Please sign in to comment.