Skip to content

Commit 18b537c

Browse files
committed
Add command to refresh the scoreboard cache for all contests.
Also add the command to the upgrade command.
1 parent 3ae5a15 commit 18b537c

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

doc/manual/upgrading.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ transferring the configuration settings from the old version.
1717
After upgrading the files, you can run ``dj_setup_database upgrade``
1818
to migrate the database.
1919

20-
If you have any active contests, we recommend to run "Refresh
21-
scoreboard cache" from the DOMjudge web interface after the upgrade.
22-
2320
Upgrading from pre-7.0 versions
2421
-------------------------------
2522
The upgrade procedure described above works from DOMjudge 7.0

sql/dj_setup_database.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ upgrade)
363363

364364
symfony_console doctrine:migrations:migrate -n
365365
DBUSER=$domjudge_DBUSER PASSWD=$domjudge_PASSWD symfony_console domjudge:load-default-data
366+
367+
symfony_console domjudge:refresh-cache
366368
verbose "DOMjudge database upgrade completed."
367369
;;
368370

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace App\Command;
4+
5+
use App\Entity\Contest;
6+
use App\Service\ScoreboardService;
7+
use Doctrine\ORM\EntityManagerInterface;
8+
use Symfony\Component\Console\Attribute\AsCommand;
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
use Symfony\Component\Console\Style\SymfonyStyle;
13+
14+
#[AsCommand(
15+
name: 'domjudge:refresh-cache',
16+
description: 'Refreshes the scoreboard caches for all contests'
17+
)]
18+
class RefreshCacheCommand extends Command
19+
{
20+
public function __construct(
21+
protected readonly EntityManagerInterface $em,
22+
protected readonly ScoreboardService $scoreboardService,
23+
) {
24+
parent::__construct();
25+
}
26+
27+
protected function execute(InputInterface $input, OutputInterface $output): int
28+
{
29+
$style = new SymfonyStyle($input, $output);
30+
31+
$contests = $this->em->getRepository(Contest::class)->findAll();
32+
foreach ($contests as $contest) {
33+
$this->scoreboardService->refreshCache($contest);
34+
$style->success("Refreshed cache for contest {$contest->getName()}.");
35+
}
36+
37+
return Command::SUCCESS;
38+
}
39+
}

0 commit comments

Comments
 (0)