Skip to content

Commit

Permalink
Merge pull request #608 from enough-mistakes/leaderboard-fix
Browse files Browse the repository at this point in the history
Fixed leaderboard rescue count
  • Loading branch information
SuperManifolds authored Jan 23, 2021
2 parents 331ef99 + ff9fd0a commit f77f8c3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/routes/Statistics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ function leaderboardCountQuery (filterName = false) {
* @returns {string} SQL query
*/
function leaderboardQuery (order, filterName = false) {
const nameFilterQuery = `
INNER JOIN "Rats" matchRat ON matchRat."userId" = "Users"."id" AND matchRat."name" ILIKE $name`
const nameFilterQuery = `AND bool_or("Rats".name ILIKE $name)`

const filter = filterName ? nameFilterQuery : ''

Expand Down Expand Up @@ -227,7 +226,6 @@ WITH "RescueStats" AS (
LEFT JOIN "Rats" AS "displayRat" ON "displayRat"."id" = "Users"."displayRatId"
LEFT JOIN "RescueRats" ON "RescueRats"."ratId" = "Rats"."id"
LEFT JOIN "Rescues" ON "Rescues"."id" = "RescueRats"."rescueId"
${filter}
WHERE
"Users"."deletedAt" IS NULL AND
"Rescues"."deletedAt" IS NULL
Expand All @@ -236,6 +234,7 @@ WITH "RescueStats" AS (
"Rescues"."outcome" = 'success' AND
"Rescues"."firstLimpetId" = "Rats"."id"
THEN 1 ELSE 0 END) > 0
${filter}
)
SELECT
"RescueStats"."id" AS "id",
Expand Down

0 comments on commit f77f8c3

Please sign in to comment.