Skip to content

Commit 6804d65

Browse files
committed
BUGFIX:
- /stats did not send the (deprecated) module structure
1 parent f47b3b2 commit 6804d65

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

plugins/restapi/commands.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,28 @@ async def stats(self, nick: str = Form(...), date: Optional[str] = Form(None),
668668
data['kdr'] = data['kills'] / data['deaths'] if data['deaths'] > 0 else data['kills']
669669
data['kdr_pvp'] = data['kills_pvp'] / data['deaths_pvp'] if data['deaths_pvp'] > 0 else data['kills_pvp']
670670

671+
await cursor.execute("""
672+
SELECT slot AS "module", SUM(kills) AS "kills"
673+
FROM statistics
674+
WHERE player_ucid = %s
675+
GROUP BY 1
676+
HAVING SUM(kills) > 1
677+
ORDER BY 2 DESC
678+
""", (ucid,))
679+
data['killsByModule'] = await cursor.fetchall()
680+
await cursor.execute("""
681+
SELECT slot AS "module",
682+
CASE
683+
WHEN SUM(deaths) = 0 THEN SUM(kills)
684+
ELSE SUM(kills) / SUM(deaths::DECIMAL) END AS "kdr"
685+
FROM statistics
686+
WHERE player_ucid = %s
687+
GROUP BY 1
688+
HAVING SUM(kills) > 1
689+
ORDER BY 2 DESC
690+
""", (ucid,))
691+
data['kdrByModule'] = await cursor.fetchall()
692+
671693
return PlayerStats.model_validate(data)
672694

673695
async def modulestats(self, nick: str = Form(...), date: Optional[str] = Form(None),

0 commit comments

Comments
 (0)