Skip to content
Open
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
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
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
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

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

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

When are we setting the seen to true? I assume we already do this.

Copy link
Contributor Author

@cubercsl cubercsl Nov 26, 2025

Choose a reason for hiding this comment

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

When are we setting the seen to true? I assume we already do this.

<tr class="{{ classes }}">
<td>
<a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %}>
{{ submission.submittime | printtime(null, submission.contest) }}
</a>
</td>
<td class="probid">
<a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %} title="{{ submission.problem.name }}">
{{ submission.contestProblem | problemBadge }}
</a>
</td>
<td class="langid">
<a data-ajax-modal data-ajax-modal-after="markSeen" {% if link %}href="{{ link }}"{% endif %} title="{{ submission.language.name }}">
{{ submission.language.langid }}
</a>
</td>
<td>

When click submission and see detail in team home page.

BTW: We track notification sent status by cookie. It might be unnecessary to use seen for filtering in this place.


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
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