Skip to content

Commit 450ec5d

Browse files
nickygerritsenvmcj
authored andcommitted
Add pagination to submission lists
Fixes #2511
1 parent e335f32 commit 450ec5d

29 files changed

+533
-137
lines changed

webapp/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"friendsofsymfony/rest-bundle": "^3.5",
6868
"ircmaxell/password-compat": "*",
6969
"jms/serializer-bundle": "^5.2",
70+
"knplabs/knp-paginator-bundle": "^6.6",
7071
"league/commonmark": "^2.3",
7172
"mbostock/d3": "^3.5",
7273
"nelmio/api-doc-bundle": "^4.11",

webapp/composer.lock

Lines changed: 257 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webapp/config/bundles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
1919
Sentry\SentryBundle\SentryBundle::class => ['prod' => true],
2020
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
21+
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
2122
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
knp_paginator:
2+
default_options:
3+
default_limit: 50
4+
template:
5+
pagination: '@KnpPaginator/Pagination/bootstrap_v5_pagination.html.twig'

webapp/src/Controller/API/MetricsController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ public function prometheusAction(): Response
102102
/** @var Submission[] $submissions */
103103
[$submissions, $submissionCounts] = $this->submissionService->getSubmissionList(
104104
[$contest->getCid() => $contest],
105-
new SubmissionRestriction(visible: true)
105+
new SubmissionRestriction(visible: true),
106+
paginated: false
106107
);
107108
foreach ($submissionCounts as $kind => $count) {
108109
if (!array_key_exists('submissions_' . $kind, $m)) {

webapp/src/Controller/Jury/LanguageController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ public function viewAction(Request $request, SubmissionService $submissionServic
195195
/** @var Submission[] $submissions */
196196
[$submissions, $submissionCounts] = $submissionService->getSubmissionList(
197197
$this->dj->getCurrentContests(honorCookie: true),
198-
new SubmissionRestriction(languageId: $language->getLangid())
198+
new SubmissionRestriction(languageId: $language->getLangid()),
199+
page: $request->query->getInt('submissions_page', 1),
199200
);
200201

201202
$data = [

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use Doctrine\ORM\NoResultException;
3030
use Doctrine\ORM\Query\Expr\Join;
3131
use Exception;
32+
use Knp\Component\Pager\Pagination\PaginationInterface;
3233
use Symfony\Component\HttpFoundation\File\UploadedFile;
3334
use Symfony\Component\HttpFoundation\RedirectResponse;
3435
use Symfony\Component\HttpFoundation\Request;
@@ -487,10 +488,11 @@ public function viewAction(Request $request, SubmissionService $submissionServic
487488
return $this->redirectToRoute('jury_problem', ['probId' => $probId]);
488489
}
489490

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

496498
$type = '';

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Doctrine\ORM\NonUniqueResultException;
2727
use Doctrine\ORM\NoResultException;
2828
use Doctrine\ORM\Query\Expr\Join;
29+
use Knp\Component\Pager\Pagination\PaginationInterface;
2930
use Symfony\Component\Form\FormFactoryInterface;
3031
use Symfony\Component\HttpFoundation\Request;
3132
use Symfony\Component\HttpFoundation\RequestStack;
@@ -330,7 +331,7 @@ public function viewAction(
330331
$verdictTable[$originalVerdict->getResult()][$newVerdict->getResult()][] = $submitid;
331332
}
332333

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

365-
/** @var Submission[] $submissions */
366+
/** @var PaginationInterface<int, Submission> $submissions */
366367
[$submissions, $submissionCounts] = $submissionService->getSubmissionList(
367368
$this->dj->getCurrentContests(honorCookie: true),
368-
$restrictions
369+
$restrictions,
370+
page: $request->query->getInt('page', 1),
369371
);
370372

371373
$repetitions = $this->em->createQueryBuilder()

webapp/src/Controller/Jury/ShadowDifferencesController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ public function indexAction(
205205
[$submissions, $submissionCounts] = $this->submissions->getSubmissionList(
206206
$this->dj->getCurrentContests(honorCookie: true),
207207
$restrictions,
208+
page: $request->query->getInt('page', 1),
208209
showShadowUnverified: true
209210
);
210211

0 commit comments

Comments
 (0)