Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d6d9118

Browse files
committed
feat: add submission notification
1 parent d8cbf48 commit d6d9118

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

‎webapp/public/js/domjudge.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ function toggleRefresh($url, $after, usingAjax) {
660660
$('#refresh-toggle').text(text);
661661
}
662662

663-
function updateClarifications()
663+
function updateTeamNotifications()
664664
{
665665
$.ajax({
666666
url: $('#menuDefault').data('update-url'),
@@ -677,6 +677,14 @@ function updateClarifications()
677677
'link': domjudge_base_url + '/team/clarifications/'+data[i].clarid,
678678
'body': data[i].body });
679679
}
680+
data = json['unread_submissions'];
681+
num = data.length;
682+
for (let i = 0; i < num; i++) {
683+
sendNotification(`Submission ${data[i].submissionid}: ${data[i].result}`,
684+
{'tag': 'sub_' + data[i].submissionid + '_judge_' + data[i].judgingid,
685+
'link': domjudge_base_url + '/team/submission/'+data[i].submissionid,
686+
'body': `Submission ${data[i].submissionid} received a new result: ${data[i].result}` });
687+
}
680688
}
681689
})
682690
}

‎webapp/src/Controller/Team/MiscController.php‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ public function homeAction(Request $request): Response
143143
#[Route(path: '/updates', methods: ['GET'], name: 'team_ajax_updates')]
144144
public function updatesAction(): JsonResponse
145145
{
146-
return $this->json(['unread_clarifications' => $this->dj->getUnreadClarifications()]);
146+
return $this->json([
147+
'unread_clarifications' => $this->dj->getUnreadClarifications(),
148+
'unread_submissions' => $this->dj->getUnreadJudgements(),
149+
]);
147150
}
148151

149152
#[Route(path: '/change-contest/{contestId<-?\d+>}', name: 'team_change_contest')]

‎webapp/src/Service/DOMJudgeService.php‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,53 @@ public function getUnreadClarifications(): array
320320
return $unreadClarifications;
321321
}
322322

323+
/**
324+
* @return array<array{submissionid: int, judgingid: int, body: string}>
325+
*/
326+
327+
public function getUnreadJudgements(): array
328+
{
329+
$user = $this->getUser();
330+
$team = $user->getTeam();
331+
$contest = $this->getCurrentContest($team->getTeamId());
332+
$unreadJudgements = [];
333+
if ($contest === null) {
334+
return $unreadJudgements;
335+
}
336+
337+
$queryBuilder = $this->em->createQueryBuilder()
338+
->from(Judging::class, 'j')
339+
->select('j, c, s')
340+
->leftJoin('j.contest', 'c')
341+
->leftJoin('j.submission', 's')
342+
->groupBy('j.judgingid')
343+
->orderBy('j.judgingid')
344+
->andWhere('j.contest = :cid')
345+
->setParameter('cid', $contest->getCid())
346+
->andWhere('j.result IS NOT NULL')
347+
->andWhere('s.team = :team')
348+
->setParameter('team', $team)
349+
->andWhere('s.submittime < c.endtime')
350+
->andWhere('j.valid = 1')
351+
->andWhere('j.seen = 0');
352+
353+
if ($this->config->get('verification_required')) {
354+
$queryBuilder->andWhere('j.verified = 1');
355+
}
356+
357+
/** @var Judging[] $judgings */
358+
$judgings = $queryBuilder->getQuery()->getResult();
359+
360+
foreach ($judgings as $j) {
361+
$unreadJudgements[] = [
362+
'submissionid' => $j->getSubmissionId(),
363+
'judgingid' => $j->getJudgingid(),
364+
'result' => $j->getResult()
365+
];
366+
}
367+
return $unreadJudgements;
368+
}
369+
323370
/**
324371
* @return array{clarifications: array<array{clarid: int, body: string}>,
325372
* judgehosts: array<array{hostname: string, polltime: float}>,

‎webapp/templates/team/base.html.twig‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
$('#notify_disable').removeClass('d-none');
4444
}
4545
}
46-
updateClarifications();
47-
setInterval(updateClarifications, 20000);
46+
updateTeamNotifications();
47+
setInterval(updateTeamNotifications, 20000);
4848
});
4949
5050
</script>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /