Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Return all obtained levels for badges #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions src/ASP/aspx/getawardsinfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,28 @@

// We will not use a view this time, performance is key
$query = <<<SQL
-- COUNT all rows for each medal to get a single row per medal
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`
FROM player_award AS a
LEFT JOIN round AS r ON a.round_id = r.id
WHERE a.player_id=$pid
WHERE a.player_id=$pid AND a.award_id BETWEEN 2000000 AND 2999999
GROUP BY a.player_id, a.award_id
ORDER BY a.player_id;
UNION ALL
-- Don't GROUP badge/ribbon rows since we need to return all levels invidially (for ribbons)
-- (selecting 0 as first since neither ribbons nor badges can be awarded more than once)
SELECT a.award_id AS `id`, a.player_id AS `pid`, r.time_end AS `earned`, 0 AS `first`, `level`
FROM player_award AS a
LEFT JOIN round AS r ON a.round_id = r.id
WHERE a.player_id=$pid AND a.award_id NOT BETWEEN 2000000 AND 2999999
ORDER BY `id`, `level`;
SQL;


// Query and get all of the Players awards
$stmt = $connection->query($query);
while ($award = $stmt->fetch())
{
// Ribbons will get a 'first' value of 0
$id = (int)$award['id'];
$first = (($id > 2000000) && ($id < 3000000)) ? $award['first'] : 0;
$Response->writeDataLine($id, $award['level'], $award['earned'], $first);
$Response->writeDataLine($award['id'], $award['level'], $award['earned'], $award['first']);
}

$Response->send();
Expand Down
Loading