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

View File

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