feature (stats): Weekly and monthly goals.

Add a new editing interface for weekly and monthly goals.
Textual viewing interface is currently a stub.
Add `month_timestamp` and `week_timestamp` lion properties.
This commit is contained in:
2021-12-30 11:26:58 +02:00
parent fa430b8403
commit d60a8772a3
6 changed files with 163 additions and 3 deletions

View File

@@ -4,3 +4,4 @@ from . import data
from . import profile
from . import setprofile
from . import top_cmd
from . import goals

View File

@@ -1,4 +1,6 @@
from data import Table
from cachetools import TTLCache
from data import Table, RowTable
profile_tags = Table('member_profile_tags', attach_as='profile_tags')
@@ -11,3 +13,27 @@ def get_tags_for(guildid, userid):
_extra="ORDER BY tagid ASC"
)
return [row['tag'] for row in rows]
weekly_goals = RowTable(
'member_weekly_goals',
('guildid', 'userid', 'weekid', 'study_goal', 'task_goal'),
('guildid', 'userid', 'weekid'),
cache=TTLCache(5000, 60 * 60 * 24),
attach_as='weekly_goals'
)
# NOTE: Not using a RowTable here since these will almost always be mass-selected
weekly_tasks = Table('member_weekly_goal_tasks')
monthly_goals = RowTable(
'member_monthly_goals',
('guildid', 'userid', 'monthid', 'study_goal', 'task_goal'),
('guildid', 'userid', 'monthid'),
cache=TTLCache(5000, 60 * 60 * 24),
attach_as='monthly_goals'
)
monthly_tasks = Table('member_monthly_goal_tasks')

View File

@@ -167,7 +167,7 @@ async def cmd_setprofile(ctx, flags):
# Ack with user
embed = discord.Embed(
colour=discord.Colour.green(),
description="Profile tags updated!"
title="Profile tags updated!"
)
embed.add_field(
name="New tags",
@@ -175,10 +175,14 @@ async def cmd_setprofile(ctx, flags):
)
if deleted_rows:
embed.add_field(
name="Previous tags",
name="Replaced tags",
value='\n'.join(row['tag'].upper() for row in deleted_rows),
inline=False
)
if len(to_add) == 1:
embed.set_footer(
text=f"TIP: Add multiple tags with {ctx.best_prefix}setprofile tag1, tag2, ..."
)
await ctx.reply(embed=embed)
else:
# No input was provided