Skip to content

Commit

Permalink
Add pagination to submission lists
Browse files Browse the repository at this point in the history
Fixes #2511
  • Loading branch information
nickygerritsen committed Dec 15, 2024
1 parent 0cfe72c commit a103327
Show file tree
Hide file tree
Showing 29 changed files with 533 additions and 137 deletions.
1 change: 1 addition & 0 deletions webapp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"friendsofsymfony/rest-bundle": "^3.5",
"ircmaxell/password-compat": "*",
"jms/serializer-bundle": "^5.2",
"knplabs/knp-paginator-bundle": "^6.6",
"league/commonmark": "^2.3",
"mbostock/d3": "^3.5",
"nelmio/api-doc-bundle": "^4.11",
Expand Down
258 changes: 257 additions & 1 deletion webapp/composer.lock

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

1 change: 1 addition & 0 deletions webapp/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Sentry\SentryBundle\SentryBundle::class => ['prod' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
];
5 changes: 5 additions & 0 deletions webapp/config/packages/knp_paginator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
knp_paginator:
default_options:
default_limit: 50
template:
pagination: '@KnpPaginator/Pagination/bootstrap_v5_pagination.html.twig'
3 changes: 2 additions & 1 deletion webapp/src/Controller/API/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function prometheusAction(): Response
/** @var Submission[] $submissions */
[$submissions, $submissionCounts] = $this->submissionService->getSubmissionList(
[$contest->getCid() => $contest],
new SubmissionRestriction(visible: true)
new SubmissionRestriction(visible: true),
paginated: false
);
foreach ($submissionCounts as $kind => $count) {
if (!array_key_exists('submissions_' . $kind, $m)) {
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/Controller/Jury/LanguageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public function viewAction(Request $request, SubmissionService $submissionServic
/** @var Submission[] $submissions */
[$submissions, $submissionCounts] = $submissionService->getSubmissionList(
$this->dj->getCurrentContests(honorCookie: true),
new SubmissionRestriction(languageId: $language->getLangid())
new SubmissionRestriction(languageId: $language->getLangid()),
page: $request->query->getInt('submissions_page', 1),
);

$data = [
Expand Down
4 changes: 3 additions & 1 deletion webapp/src/Controller/Jury/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\Query\Expr\Join;
use Exception;
use Knp\Component\Pager\Pagination\PaginationInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -487,10 +488,11 @@ public function viewAction(Request $request, SubmissionService $submissionServic
return $this->redirectToRoute('jury_problem', ['probId' => $probId]);
}

/** @var Submission[] $submissions */
/** @var PaginationInterface<int, Submission> $submissions */
[$submissions, $submissionCounts] = $submissionService->getSubmissionList(
$this->dj->getCurrentContests(honorCookie: true),
new SubmissionRestriction(problemId: $problem->getProbid()),
page: $request->query->getInt('page', 1),
);

$type = '';
Expand Down
8 changes: 5 additions & 3 deletions webapp/src/Controller/Jury/RejudgingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Doctrine\ORM\NonUniqueResultException;
use Doctrine\ORM\NoResultException;
use Doctrine\ORM\Query\Expr\Join;
use Knp\Component\Pager\Pagination\PaginationInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -330,7 +331,7 @@ public function viewAction(
$verdictTable[$originalVerdict->getResult()][$newVerdict->getResult()][] = $submitid;
}

$viewTypes = [0 => 'newest', 1 => 'unverified', 2 => 'unjudged', 3 => 'diff', 4 => 'all'];
$viewTypes = [0 => 'unverified', 1 => 'unjudged', 2 => 'diff', 3 => 'all'];
$defaultView = 'diff';
$onlyAHandfulOfSubmissions = $rejudging->getSubmissions()->count() <= 5;
if ($onlyAHandfulOfSubmissions) {
Expand Down Expand Up @@ -362,10 +363,11 @@ public function viewAction(
$restrictions->result = $newverdict;
}

/** @var Submission[] $submissions */
/** @var PaginationInterface<int, Submission> $submissions */
[$submissions, $submissionCounts] = $submissionService->getSubmissionList(
$this->dj->getCurrentContests(honorCookie: true),
$restrictions
$restrictions,
page: $request->query->getInt('page', 1),
);

$repetitions = $this->em->createQueryBuilder()
Expand Down
1 change: 1 addition & 0 deletions webapp/src/Controller/Jury/ShadowDifferencesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public function indexAction(
[$submissions, $submissionCounts] = $this->submissions->getSubmissionList(
$this->dj->getCurrentContests(honorCookie: true),
$restrictions,
page: $request->query->getInt('page', 1),
showShadowUnverified: true
);

Expand Down
Loading

0 comments on commit a103327

Please sign in to comment.