Skip to content

Commit 3d8bab5

Browse files
committed
CHANGES:
- RestAPI: /leaderboard query searches in resultset only
1 parent 125e18b commit 3d8bab5

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

plugins/restapi/commands.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,6 @@ async def leaderboard(self, what: Literal['kills', 'kills_pvp', 'deaths', 'kdr',
366366
join = "JOIN missions m ON s.mission_id = m.id AND m.server_name = %(server_name)s"
367367
else:
368368
join = ""
369-
if query:
370-
where = "WHERE p.name ILIKE %(query)s"
371-
else:
372-
where = ""
373369

374370
async with self.apool.connection() as conn:
375371
async with conn.cursor(row_factory=dict_row) as cursor:
@@ -390,7 +386,6 @@ async def leaderboard(self, what: Literal['kills', 'kills_pvp', 'deaths', 'kdr',
390386
FROM statistics s
391387
JOIN players p ON s.player_ucid = p.ucid
392388
{join}
393-
{where}
394389
GROUP BY 1, 2
395390
ORDER BY {order_column} {order}
396391
LIMIT %(limit)s
@@ -413,7 +408,7 @@ async def leaderboard(self, what: Literal['kills', 'kills_pvp', 'deaths', 'kdr',
413408
del row['total_count']
414409

415410
return LeaderBoard.model_validate({
416-
'items': [row for row in rows],
411+
'items': [row for row in rows if not query or query.casefold() in row['name'].casefold()],
417412
'total_count': total_count,
418413
'offset': offset
419414
})

0 commit comments

Comments
 (0)