add graph to daily stats

This commit is contained in:
transcental 2025-08-26 12:39:09 +01:00
parent fe5c151577
commit 8a7fef02db
3 changed files with 37 additions and 6 deletions

View file

@ -5,6 +5,7 @@ from zoneinfo import ZoneInfo
from nephthys.utils.env import env
from nephthys.utils.logging import send_heartbeat
from nephthys.views.home.components.ticket_status_pie import get_ticket_status_pie_chart
from prisma.enums import TicketStatus
@ -122,6 +123,8 @@ async def send_daily_stats():
else:
daily_leaderboard_str = "\n".join(daily_leaderboard_lines)
pie_chart = await get_ticket_status_pie_chart()
msg = f"""
um, um, hi there! hope i'm not disturbing you, but i just wanted to let you know that i've got some stats for you! :rac_cute:
@ -145,9 +148,38 @@ you managed to close a whopping *{prev_day_closed}* tickets in the last 24 hours
{daily_leaderboard_str}
"""
blocks = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":rac_cute: daily stats!",
"emoji": True,
},
},
{"type": "divider"},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": msg,
},
},
{"type": "divider"},
pie_chart,
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "_i hope you found these stats helpful!_ :rac_cute:",
}
],
},
]
await env.slack_client.chat_postMessage(
channel=env.slack_bts_channel,
text=msg,
channel=env.slack_bts_channel, blocks=blocks
)
logging.info("Daily stats message sent successfully.")

View file

@ -10,11 +10,10 @@ from nephthys.utils.graphs.pie import generate_pie_chart
from nephthys.utils.litterbox import upload_litter
from nephthys.utils.time import is_day
from prisma.enums import TicketStatus
from prisma.models import User
async def get_ticket_status_pie_chart(helper: User, tz: timezone):
is_daytime = is_day(tz)
async def get_ticket_status_pie_chart(tz: timezone | None = None):
is_daytime = is_day(tz) if tz else True
if is_daytime:
text_colour = "black"

View file

@ -17,7 +17,7 @@ async def get_helper_view(user: User):
tz_string = slack_user.get("tz", "Europe/London")
tz = pytz.timezone(tz_string)
pie_chart = await get_ticket_status_pie_chart(user, tz)
pie_chart = await get_ticket_status_pie_chart(tz)
leaderboard = await get_leaderboard_view()
btns = get_buttons(user, "dashboard")