Skip to content

Preparation for improving the daily summary message#124

Merged
MMK21Hub merged 7 commits intohackclub:mainfrom
MMK21Hub:stale-v2-without-migrations
Nov 29, 2025
Merged

Preparation for improving the daily summary message#124
MMK21Hub merged 7 commits intohackclub:mainfrom
MMK21Hub:stale-v2-without-migrations

Conversation

@MMK21Hub
Copy link
Copy Markdown
Collaborator

  • The timestamp of and the user type (helper, question-asker, or someone else) who sent the last message in each question thread is now tracked in the database
    • this is to allow finding stale/forgotten tickets without needing to read conversation history en masse
    • also formatted the Prisma schema
  • Add /data to .gitignore to provide an easy place to store a dev database
  • Ensure the all-time leaderboard only contains people who have resolved tickets (Daily summary message pings people even if they closed 0 tickets #96)

Arguably this could've been 3 PRs? I grouped them into one to try to reduce the noise created by creating/reviewing/merging lots of PRs.

As mentioned in the PR title, I plan to use the new database fields to improve the daily summary message!

Copilot AI review requested due to automatic review settings November 29, 2025 11:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prepares the codebase for improving the daily summary message by introducing database tracking of message activity in ticket threads. It adds new fields to track when the last message was sent and who sent it (author, helper, or other), enables better identification of stale tickets, and fixes the all-time leaderboard to only include helpers who have actually resolved tickets.

Key Changes:

  • Added lastMsgAt and lastMsgBy fields to the Ticket model with a new UserType enum to categorize message senders
  • Modified message handling to track all messages in threads (not just helper messages) for future stale ticket detection
  • Fixed leaderboard query to filter users who have actually closed tickets using closedTickets: {some: {}}

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.

File Description
prisma/schema.prisma Added UserType enum and lastMsgAt/lastMsgBy fields to Ticket model; formatted schema for consistency
nephthys/events/message.py Updated message handler to track last message metadata for all users and refactored helper message detection logic
nephthys/tasks/daily_stats.py Fixed all-time leaderboard query to only include helpers who have closed at least one ticket
.gitignore Added data/ directory for local development database storage
Comments suppressed due to low confidence (1)

nephthys/events/message.py:103

  • The function performs two separate database updates to the same ticket (lines 78-88 and 92-103). This could be optimized into a single update when both conditions apply (i.e., when a helper sends a non-macro message to a non-closed ticket). Consider combining the updates to reduce database round trips.
    await env.db.ticket.update(
        where={"msgTs": event["thread_ts"]},
        data={
            "lastMsgAt": datetime.now(),
            "lastMsgBy": UserType.AUTHOR
            if is_author
            else UserType.HELPER
            if is_helper
            else UserType.OTHER,
        },
    )

    # Ensure the ticket is assigned to the helper who last sent a message
    if db_user and db_user.helper and ticket_message.status != TicketStatus.CLOSED:
        await env.db.ticket.update(
            where={"msgTs": event["thread_ts"]},
            data={
                "assignedTo": {"connect": {"id": db_user.id}},
                "status": TicketStatus.IN_PROGRESS,
                "assignedAt": (
                    datetime.now()
                    if not ticket_message.assignedAt
                    else ticket_message.assignedAt
                ),
            },
        )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread nephthys/events/message.py Outdated
Comment thread nephthys/events/message.py
Comment thread prisma/schema.prisma
Comment thread nephthys/events/message.py
@MMK21Hub MMK21Hub added this pull request to the merge queue Nov 29, 2025
Merged via the queue into hackclub:main with commit 14784f7 Nov 29, 2025
4 checks passed
@MMK21Hub MMK21Hub deleted the stale-v2-without-migrations branch November 29, 2025 11:26
@MMK21Hub MMK21Hub restored the stale-v2-without-migrations branch November 30, 2025 00:33
@transcental transcental mentioned this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants