Skip to content

Add command to refresh the scoreboard cache for all contests. #2971

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

Merged
merged 1 commit into from
Mar 22, 2025
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
3 changes: 0 additions & 3 deletions doc/manual/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ transferring the configuration settings from the old version.
After upgrading the files, you can run ``dj_setup_database upgrade``
to migrate the database.

If you have any active contests, we recommend to run "Refresh
scoreboard cache" from the DOMjudge web interface after the upgrade.

Upgrading from pre-7.0 versions
-------------------------------
The upgrade procedure described above works from DOMjudge 7.0
Expand Down
2 changes: 2 additions & 0 deletions sql/dj_setup_database.in
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ upgrade)

symfony_console doctrine:migrations:migrate -n
DBUSER=$domjudge_DBUSER PASSWD=$domjudge_PASSWD symfony_console domjudge:load-default-data

symfony_console domjudge:refresh-cache
verbose "DOMjudge database upgrade completed."
;;

Expand Down
39 changes: 39 additions & 0 deletions webapp/src/Command/RefreshCacheCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php declare(strict_types=1);

namespace App\Command;

use App\Entity\Contest;
use App\Service\ScoreboardService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'domjudge:refresh-cache',
description: 'Refreshes the scoreboard caches for all contests'
)]
class RefreshCacheCommand extends Command
{
public function __construct(
protected readonly EntityManagerInterface $em,
protected readonly ScoreboardService $scoreboardService,
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$style = new SymfonyStyle($input, $output);

$contests = $this->em->getRepository(Contest::class)->findAll();
foreach ($contests as $contest) {
$this->scoreboardService->refreshCache($contest);
$style->success("Refreshed cache for contest {$contest->getName()}.");
}

return Command::SUCCESS;
}
}
Loading