Skip to content

Introduce the concept of sort keys. #2954

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 23, 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
4 changes: 2 additions & 2 deletions doc/manual/install-domserver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ GNU/Linux, or one of its derivative distributions like Ubuntu::

sudo apt install libcgroup-dev make acl zip unzip pv mariadb-server apache2 \
php php-fpm php-gd php-cli php-intl php-mbstring php-mysql \
php-curl php-json php-xml php-zip composer ntp python3-yaml
php-curl php-json php-xml php-zip composer ntp python3-yaml php-bcmath

The following command can be used on Fedora, and related distributions like
Red Hat Enterprise Linux and Rocky Linux (before V9)::

sudo dnf install libcgroup-devel make acl zip unzip pv mariadb-server httpd \
php-gd php-cli php-intl php-mbstring php-mysqlnd php-fpm \
php-xml php-zip composer chronyd python3-pyyaml
php-xml php-zip composer chronyd python3-pyyaml php-bcmath

`nginx` can be used as an alternate web server.

Expand Down
1 change: 1 addition & 0 deletions webapp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
],
"require": {
"php": "^8.1.0",
"ext-bcmath": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-fileinfo": "*",
Expand Down
1 change: 1 addition & 0 deletions webapp/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions webapp/migrations/Version20250309122806.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250309122806 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add sort keys to rankcache, allowing us to support different scoring functions efficiently and elegantly';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE rankcache ADD sort_key_public TEXT DEFAULT \'\' NOT NULL COMMENT \'Opaque sort key for public audience.\', ADD sort_key_restricted TEXT DEFAULT \'\' NOT NULL COMMENT \'Opaque sort key for restricted audience.\'');
$this->addSql('CREATE INDEX sortKeyPublic ON rankcache (sort_key_public)');
$this->addSql('CREATE INDEX sortKeyRestricted ON rankcache (sort_key_restricted)');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP INDEX sortKeyPublic ON rankcache');
$this->addSql('DROP INDEX sortKeyRestricted ON rankcache');
$this->addSql('ALTER TABLE rankcache DROP sort_key_public, DROP sort_key_restricted');
}

public function isTransactional(): bool
{
return false;
}
}
2 changes: 1 addition & 1 deletion webapp/src/Controller/Jury/ImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ protected function getResultsHtml(
$filter = new Filter();
$filter->categories = $categoryIds;
$scoreboard = $this->scoreboardService->getScoreboard($contest, true, $filter);
$teams = $scoreboard->getTeams();
$teams = $scoreboard->getTeamsInDescendingOrder();

$teamNames = [];
foreach ($teams as $team) {
Expand Down
39 changes: 39 additions & 0 deletions webapp/src/Entity/RankCache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php declare(strict_types=1);
namespace App\Entity;

use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\ORM\Mapping as ORM;

/**
Expand All @@ -18,6 +19,8 @@
#[ORM\Index(columns: ['cid', 'points_public', 'totaltime_public', 'totalruntime_public'], name: 'order_public')]
#[ORM\Index(columns: ['cid'], name: 'cid')]
#[ORM\Index(columns: ['teamid'], name: 'teamid')]
#[ORM\Index(columns: ['sort_key_public'], name: 'sortKeyPublic')]
#[ORM\Index(columns: ['sort_key_restricted'], name: 'sortKeyRestricted')]
class RankCache
{
#[ORM\Column(options: [
Expand Down Expand Up @@ -62,6 +65,20 @@ class RankCache
#[ORM\JoinColumn(name: 'teamid', referencedColumnName: 'teamid', onDelete: 'CASCADE')]
private Team $team;

#[ORM\Column(
type: 'text',
length: AbstractMySQLPlatform::LENGTH_LIMIT_TEXT,
options: ['comment' => 'Opaque sort key for public audience.', 'default' => '']
)]
private string $sortKeyPublic = '';

#[ORM\Column(
type: 'text',
length: AbstractMySQLPlatform::LENGTH_LIMIT_TEXT,
options: ['comment' => 'Opaque sort key for restricted audience.', 'default' => '']
)]
private string $sortKeyRestricted = '';

public function setPointsRestricted(int $pointsRestricted): RankCache
{
$this->points_restricted = $pointsRestricted;
Expand Down Expand Up @@ -149,4 +166,26 @@ public function getTeam(): Team
{
return $this->team;
}

public function setSortKeyPublic(string $sortKeyPublic): RankCache
{
$this->sortKeyPublic = $sortKeyPublic;
return $this;
}

public function getSortKeyPublic(): string
{
return $this->sortKeyPublic;
}

public function setSortKeyRestricted(string $sortKeyRestricted): RankCache
{
$this->sortKeyRestricted = $sortKeyRestricted;
return $this;
}

public function getSortKeyRestricted(): string
{
return $this->sortKeyRestricted;
}
}
2 changes: 1 addition & 1 deletion webapp/src/Service/AwardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function loadAwards(Contest $contest, Scoreboard $scoreboard): void
{
$group_winners = $problem_winners = $problem_shortname = [];
$groups = [];
foreach ($scoreboard->getTeams() as $team) {
foreach ($scoreboard->getTeamsInDescendingOrder() as $team) {
$teamid = $team->getExternalid();
if ($scoreboard->isBestInCategory($team)) {
$catId = $team->getCategory()->getExternalid();
Expand Down
Loading
Loading