update fetch_leaderboard_balances()
@@ -197,17 +197,11 @@ class Database(commands.Cog):
async def mass_fetch_balances(self):
return await self.db.fetch("SELECT uid, emeralds FROM users WHERE emeralds > 0 AND bot_banned = false")
- async def fetch_leaderboard_balances(self, uids: list, *, limit: int = 11):
+ async def fetch_leaderboard_balances(self, uid: int, uids: list, *, limit: int = 11):
return (
- # await self.db.fetch(
- # "SELECT uid, emeralds, ROW_NUMBER() FROM users WHERE emeralds > 0 AND bot_banned = false ORDER BY emeralds DESC LIMIT $1",
- # limit,
- # ),
- # await self.db.fetch(
- # "SELECT uid, emeralds, ROW_NUMBER() FROM users WHERE emeralds > 0 AND bot_banned = false AND uid = ANY($1::BIGINT[]) ORDER BY emeralds DESC LIMIT $2",
- # uids,
- # limit,
- # ),
+ await self.db.fetchrow(
+ "SELECT uid, emeralds, ROW_NUMBER() OVER(ORDER BY emeralds DESC) AS position FROM users WHERE uid = $1", uid
+ ),
await self.db.fetch(
"SELECT uid, emeralds, ROW_NUMBER() OVER(ORDER BY emeralds DESC) AS position FROM users WHERE emeralds > 0 AND bot_banned = false LIMIT $1",
limit,
