fix (Top): Handle empty exclude list.

This commit is contained in:
2021-09-19 13:42:40 +03:00
parent f23ba807da
commit 1a8a50538d
2 changed files with 28 additions and 12 deletions

View File

@@ -42,12 +42,20 @@ async def cmd_topcoin(ctx):
Lion.sync() Lion.sync()
# Fetch the leaderboard # Fetch the leaderboard
user_data = tables.lions.select_where( exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
guildid=ctx.guild.id, if exclude:
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]), user_data = tables.lions.select_where(
select_columns=('userid', 'coins'), guildid=ctx.guild.id,
_extra="AND coins > 0 ORDER BY coins DESC " + ("LIMIT 100" if top100 else "") userid=data.NOT(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 "")
)
# Quit early if the leaderboard is empty # Quit early if the leaderboard is empty
if not user_data: if not user_data:

View File

@@ -42,12 +42,20 @@ async def cmd_top(ctx):
Lion.sync() Lion.sync()
# Fetch the leaderboard # Fetch the leaderboard
user_data = tables.lions.select_where( exclude = [m.id for m in ctx.guild_settings.unranked_roles.members]
guildid=ctx.guild.id, if exclude:
userid=data.NOT([m.id for m in ctx.guild_settings.unranked_roles.members]), user_data = tables.lions.select_where(
select_columns=('userid', 'tracked_time'), guildid=ctx.guild.id,
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "") userid=data.NOT(exclude),
) select_columns=('userid', 'tracked_time'),
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
)
else:
user_data = tables.lions.select_where(
guildid=ctx.guild.id,
select_columns=('userid', 'tracked_time'),
_extra="AND tracked_time > 0 ORDER BY tracked_time DESC " + ("LIMIT 100" if top100 else "")
)
# Quit early if the leaderboard is empty # Quit early if the leaderboard is empty
if not user_data: if not user_data: