fix(group): hide hidden submissions

This commit is contained in:
Baoshuo Ren 2023-02-13 11:34:43 +08:00
parent fea4eea8d7
commit aa4a2fa2d1
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 16 additions and 14 deletions

View File

@ -64,18 +64,15 @@ UOJGroup::cur()->userCanView(Auth::user(), ['ensure' => true]);
<?= UOJLocale::get('news') ?>
</h2>
<ul class="mb-0">
<?php foreach (UOJGroup::cur()->getLatestGroupmatesAcceptedSubmissionIds(Auth::user()) as $id) : ?>
<?php
$submission = UOJSubmission::query($id);
$submission->setProblem();
$user = UOJUser::query($submission->info['submitter']);
?>
<li>
<?= UOJUser::getLink($user) ?>
解决了问题
<?= $submission->problem->getLink(['with' => 'id']) ?>
(<time><?= $submission->info['submit_time'] ?></time>)
</li>
<?php foreach (UOJGroup::cur()->getLatestGroupMatesAcceptedSubmissions(Auth::user()) as $submission) : ?>
<?php if ($submission->userCanView(Auth::user())) : ?>
<li>
<?= UOJUser::getLink($submission->info['submitter']) ?>
解决了问题
<?= $submission->problem->getLink(['with' => 'id']) ?>
(<time><?= $submission->info['submit_time'] ?></time>)
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
</div>

View File

@ -86,8 +86,13 @@ class UOJGroup {
]));
}
public function getLatestGroupmatesAcceptedSubmissionIds(array $user = null, int $limit = 10) {
return array_map(fn ($x) => $x['id'], DB::selectAll([
public function getLatestGroupMatesAcceptedSubmissions(array $user = null, int $limit = 10) {
return array_map(function ($x) {
$submission = UOJSubmission::query($x['id']);
$submission->setProblem();
return $submission;
}, DB::selectAll([
"select", DB::fields(["id" => "max(id)"]),
"from submissions",
"where", [