mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 14:48:41 +00:00
fix(web/group/assignment): db query perf
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
b6b8efd5fb
commit
892a56a881
@ -78,7 +78,13 @@
|
|||||||
|
|
||||||
foreach ($problem_ids as $problem_id) {
|
foreach ($problem_ids as $problem_id) {
|
||||||
$cond = "submitter = '{$user['username']}' AND problem_id = $problem_id AND submit_time <= '$submission_end_time'";
|
$cond = "submitter = '{$user['username']}' AND problem_id = $problem_id AND submit_time <= '$submission_end_time'";
|
||||||
$submission = DB::selectFirst("SELECT id, score FROM submissions INNER JOIN (SELECT MAX(score) AS score FROM submissions WHERE $cond) AS max USING (score) WHERE $cond ORDER BY submit_time DESC");
|
$max_score_query = DB::selectFirst("SELECT MAX(score) AS score FROM submissions WHERE $cond");
|
||||||
|
if ($max_score_query) {
|
||||||
|
$max_score = $max_score_query['score'];
|
||||||
|
} else {
|
||||||
|
$max_score = 0;
|
||||||
|
}
|
||||||
|
$submission = DB::selectFirst("SELECT id, score FROM submissions WHERE $cond AND score = $max_score ORDER BY submit_time DESC LIMIT 1");
|
||||||
|
|
||||||
if ($submission) {
|
if ($submission) {
|
||||||
$row['scores'][] = [
|
$row['scores'][] = [
|
||||||
|
Loading…
Reference in New Issue
Block a user