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

feat: add submission notification #3018

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

Draft
cubercsl wants to merge 1 commit into DOMjudge:main
base: main
Choose a base branch
Loading
from cubercsl:feat/submission-notification
Draft
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
10 changes: 9 additions & 1 deletion webapp/public/js/domjudge.js
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ function toggleRefresh($url, $after, usingAjax) {
$('#refresh-toggle').text(text);
}

function updateClarifications()
function updateTeamNotifications()
{
$.ajax({
url: $('#menuDefault').data('update-url'),
Expand All @@ -677,6 +677,14 @@ function updateClarifications()
'link': domjudge_base_url + '/team/clarifications/'+data[i].clarid,
'body': data[i].body });
}
data = json['unread_submissions'];
num = data.length;
for (let i = 0; i < num; i++) {
sendNotification(`Submission ${data[i].submissionid}: ${data[i].result}`,
{'tag': 'sub_' + data[i].submissionid + '_judge_' + data[i].judgingid,
'link': domjudge_base_url + '/team/submission/'+data[i].submissionid,
'body': `Submission ${data[i].submissionid} received a new result: ${data[i].result}` });
}
}
})
}
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/Controller/Team/MiscController.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ public function homeAction(Request $request): Response
#[Route(path: '/updates', methods: ['GET'], name: 'team_ajax_updates')]
public function updatesAction(): JsonResponse
{
return $this->json(['unread_clarifications' => $this->dj->getUnreadClarifications()]);
return $this->json([
'unread_clarifications' => $this->dj->getUnreadClarifications(),
'unread_submissions' => $this->dj->getUnreadJudgements(),
]);
}

#[Route(path: '/change-contest/{contestId<-?\d+>}', name: 'team_change_contest')]
Expand Down
47 changes: 47 additions & 0 deletions webapp/src/Service/DOMJudgeService.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,53 @@ public function getUnreadClarifications(): array
return $unreadClarifications;
}

/**
* @return array<array{submissionid: int, judgingid: int, result: string}>
*/

public function getUnreadJudgements(): array
{
$user = $this->getUser();
$team = $user->getTeam();
$contest = $this->getCurrentContest($team->getTeamId());
$unreadJudgements = [];
if ($contest === null) {
return $unreadJudgements;
}

$queryBuilder = $this->em->createQueryBuilder()
->from(Judging::class, 'j')
->select('j, c, s')
->leftJoin('j.contest', 'c')
->leftJoin('j.submission', 's')
->groupBy('j.judgingid')
->orderBy('j.judgingid')
->andWhere('j.contest = :cid')
->setParameter('cid', $contest->getCid())
->andWhere('j.result IS NOT NULL')
->andWhere('s.team = :team')
->setParameter('team', $team)
->andWhere('s.submittime < c.endtime')
->andWhere('j.valid = 1')
->andWhere('j.seen = 0');
Copy link
Member

@meisterT meisterT Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a migration missing? seen doesn't exist yet, does it?

Copy link
Contributor Author

@cubercsl cubercsl Jul 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#[ORM\Column(options: ['comment' => 'Whether the team has seen this judging', 'default' => 0])]
#[Serializer\Exclude]
private bool $seen = false;

But this may not be important, because the logic of whether to send notifications does not look at this field, (which is at sendNotification @ domjudge.js)

Copy link
Contributor Author

@cubercsl cubercsl Jul 6, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this SQL query is the same as the one a user access /api/contests/:cid/judgements, except it filters out entries they have ever seen (it will be marked as seen when they click the submission).

Therefore, it is also feasible to implement it directly on the frontend js instead of adding a function to the /update endpoint.


if ($this->config->get('verification_required')) {
$queryBuilder->andWhere('j.verified = 1');
}

/** @var Judging[] $judgings */
$judgings = $queryBuilder->getQuery()->getResult();

foreach ($judgings as $j) {
$unreadJudgements[] = [
'submissionid' => $j->getSubmissionId(),
'judgingid' => $j->getJudgingid(),
'result' => $j->getResult()
];
}
return $unreadJudgements;
}

/**
* @return array{clarifications: array<array{clarid: int, body: string}>,
* judgehosts: array<array{hostname: string, polltime: float}>,
Expand Down
4 changes: 2 additions & 2 deletions webapp/templates/team/base.html.twig
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
$('#notify_disable').removeClass('d-none');
}
}
updateClarifications();
setInterval(updateClarifications, 20000);
updateTeamNotifications();
setInterval(updateTeamNotifications, 20000);
});

</script>
Expand Down
Loading

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