Preparation for improving the daily summary message#124
Merged
MMK21Hub merged 7 commits intohackclub:mainfrom Nov 29, 2025
Merged
Preparation for improving the daily summary message#124MMK21Hub merged 7 commits intohackclub:mainfrom
MMK21Hub merged 7 commits intohackclub:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
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
lastMsgAtandlastMsgByfields to the Ticket model with a newUserTypeenum 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/datato.gitignoreto provide an easy place to store a dev databaseArguably 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!