(leaderboards): Update to support sessions.

Use `member_totals` to generate leaderboards instead of `members`.
Fix typo in data coin conversion.
This commit is contained in:
2021-12-04 11:36:52 +02:00
parent bb181d9039
commit 179b6ebf4e
5 changed files with 24 additions and 31 deletions

View File

@@ -46,19 +46,15 @@ async def cmd_topcoin(ctx):
exclude.update(ctx.client.objects['blacklisted_users'])
exclude.update(ctx.client.objects['ignored_members'][ctx.guild.id])
args = {
'guildid': ctx.guild.id,
'select_columns': ('userid', 'total_coins::INTEGER'),
'_extra': "AND total_coins > 0 ORDER BY total_coins DESC " + ("LIMIT 100" if top100 else "")
}
if exclude:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
userid=data.NOT(list(exclude)),
select_columns=('userid', 'coins'),
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
)
else:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
select_columns=('userid', 'coins'),
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "")
)
args['userid'] = data.NOT(list(exclude))
user_data = tables.members_totals.select_where(**args)
# Quit early if the leaderboard is empty
if not user_data: