Skip to content

Commit c34b13d

Browse files
committed
fix: Return all obtained levels for badges
1 parent df86f71 commit c34b13d

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Diff for: src/ASP/aspx/getawardsinfo.php

+11-6
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,28 @@
6060

6161
// We will not use a view this time, performance is key
6262
$query = <<<SQL
63+
-- COUNT all rows for each medal to get a single row per medal
6364
SELECT a.award_id AS `id`, a.player_id AS `pid`, MAX(r.time_end) AS `earned`, MIN(r.time_end) AS `first`, COUNT(`level`) AS `level`
6465
FROM player_award AS a
6566
LEFT JOIN round AS r ON a.round_id = r.id
66-
WHERE a.player_id=$pid
67+
WHERE a.player_id=$pid AND a.award_id BETWEEN 2000000 AND 2999999
6768
GROUP BY a.player_id, a.award_id
68-
ORDER BY a.player_id;
69+
UNION ALL
70+
-- Don't GROUP badge/ribbon rows since we need to return all levels invidially (for ribbons)
71+
-- (selecting 0 as first since neither ribbons nor badges can be awarded more than once)
72+
SELECT a.award_id AS `id`, a.player_id AS `pid`, r.time_end AS `earned`, 0 AS `first`, `level`
73+
FROM player_award AS a
74+
LEFT JOIN round AS r ON a.round_id = r.id
75+
WHERE a.player_id=$pid AND a.award_id NOT BETWEEN 2000000 AND 2999999
76+
ORDER BY `id`, `level`;
6977
SQL;
7078

7179

7280
// Query and get all of the Players awards
7381
$stmt = $connection->query($query);
7482
while ($award = $stmt->fetch())
7583
{
76-
// Ribbons will get a 'first' value of 0
77-
$id = (int)$award['id'];
78-
$first = (($id > 2000000) && ($id < 3000000)) ? $award['first'] : 0;
79-
$Response->writeDataLine($id, $award['level'], $award['earned'], $first);
84+
$Response->writeDataLine($award['id'], $award['level'], $award['earned'], $award['first']);
8085
}
8186

8287
$Response->send();

0 commit comments

Comments
 (0)