ui(stats): Improve visibility of season start.

This commit is contained in:
2023-09-11 09:46:02 +03:00
parent 6cc253e428
commit 76dc6a4566
6 changed files with 61 additions and 18 deletions

View File

@@ -141,13 +141,7 @@ class StatsCog(LionCog):
# Send update ack
if modified:
# TODO
description = t(_p(
'cmd:configure_statistics|resp:success|desc',
"Activity ranks and season leaderboard will now be measured from {season_start}."
)).format(
season_start=setting_season_start.formatted
)
description = setting_season_start.update_message
embed = discord.Embed(
colour=discord.Colour.brand_green(),
description=description

View File

@@ -94,7 +94,8 @@ class StatisticsSettings(SettingGroup):
'guildset:season_start|long_desc',
"Activity ranks will be determined based on tracked activity since this time, "
"and the leaderboard will display activity since this time by default. "
"Unset to disable seasons and use all-time statistics instead."
"Unset to disable seasons and use all-time statistics instead.\n"
"Provided dates and times are assumed to be in the guild `timezone`, so set this first!"
)
_accepts = _p(
'guildset:season_start|accepts',
@@ -134,7 +135,8 @@ class StatisticsSettings(SettingGroup):
resp = t(_p(
'guildset:season_start|set_response|set',
"The leaderboard season and activity ranks will now count from {timestamp}. "
"Member ranks will update when they are next active. Use {rank_cmd} to refresh immediately."
"Member ranks will update when they are next active.\n"
"Use {rank_cmd} and press **Refresh Member Ranks** to refresh all ranks immediately."
)).format(
timestamp=self.formatted,
rank_cmd=bot.core.mention_cmd('ranks')
@@ -143,7 +145,8 @@ class StatisticsSettings(SettingGroup):
resp = t(_p(
'guildset:season_start|set_response|unset',
"The leaderboard and activity ranks will now count all-time statistics. "
"Member ranks will update when they are next active. Use {rank_cmd} to refresh immediately."
"Member ranks will update when they are next active.\n"
"Use {rank_cmd} and press **Refresh Member Ranks** to refresh all ranks immediately."
)).format(rank_cmd=bot.core.mention_cmd('ranks'))
return resp

View File

@@ -90,6 +90,8 @@ class LeaderboardUI(StatsUI):
periods[LBPeriod.DAY] = lguild.today
periods[LBPeriod.WEEK] = lguild.week_start
periods[LBPeriod.MONTH] = lguild.month_start
alltime = (lguild.data.first_joined_at or interaction.guild.created_at).astimezone(lguild.timezone)
periods[LBPeriod.ALLTIME] = alltime
self.period_starts = periods
self.focused = True
@@ -432,28 +434,37 @@ class LeaderboardUI(StatsUI):
"""
Generate UI message arguments from stored data
"""
t = self.bot.translator.t
if self.card is not None:
period_start = self.period_starts[self.current_period]
header = t(_p(
'ui:leaderboard|since',
"Counting statistics since {timestamp}"
)).format(timestamp=discord.utils.format_dt(period_start))
args = MessageArgs(
embed=None,
content=header,
file=self.card.as_file('leaderboard.png')
)
else:
t = self.bot.translator.t
if self.stat_type is StatType.VOICE:
empty_description = t(_p(
'ui:leaderboard|mode:voice|message:empty|desc',
"There has been no voice activity in this period!"
"There has been no voice activity since {timestamp}"
))
elif self.stat_type is StatType.TEXT:
empty_description = t(_p(
'ui:leaderboard|mode:text|message:empty|desc',
"There has been no message activity in this period!"
"There has been no message activity since {timestamp}"
))
elif self.stat_type is StatType.ANKI:
empty_description = t(_p(
'ui:leaderboard|mode:anki|message:empty|desc',
"There have been no Anki cards reviewed in this period!"
"There have been no Anki cards reviewed since {timestamp}"
))
empty_description = empty_description.format(
timestamp=discord.utils.format_dt(self.period_starts[self.current_period])
)
embed = discord.Embed(
colour=discord.Colour.orange(),
title=t(_p(
@@ -462,7 +473,7 @@ class LeaderboardUI(StatsUI):
)),
description=empty_description
)
args = MessageArgs(embed=embed, files=[])
args = MessageArgs(content=None, embed=embed, files=[])
return args
async def refresh_components(self):