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
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
  • Loading branch information
vmcj committed Aug 31, 2023
1 parent 8b7fd31 commit 5a46b52
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 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: hide_teams_scoreboard_condition
type: int
default_value: 0
public: true
description: Hide teams on the scoreboard?
options:
0: never
1: when never logged in
2: when didn't submit
- 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 HIDE_TEAM_NEVER = 0;
final public const HIDE_TEAM_NO_LOGIN = 1;
final public const HIDE_TEAM_NO_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());
}

$hide_filter = $this->config->get('hide_teams_scoreboard_condition');
if (!$jury) {
$queryBuilder->andWhere('tc.visible = 1');
if ($hide_filter === self::HIDE_TEAM_NO_LOGIN) {
$queryBuilder
->join('t.users', 'u', Join::WITH, 'u.last_login IS NOT NULL');
} elseif ($hide_filter === self::HIDE_TEAM_NO_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

0 comments on commit 5a46b52

Please sign in to comment.