Skip to content

Conversation

@DylanDevelops
Copy link
Owner

This pull request introduces several changes to the game context and user management systems, focusing on updating user streaks and handling inactive users. The most important changes include adding a mutation to update user streaks, creating a cron job to reset inactive streaks, and modifying the schema for user data.

Game Context Changes:

  • Added updateStreak mutation to the GameProvider to update user streaks after each round. [1] [2]

User Management Changes:

  • Added a daily cron job to reset inactive user streaks.
  • Modified the schema to replace lastParticipationDate with lastPlayedTimestamp for better timestamp handling.
  • Replaced the internalMutation for updating streaks with a more detailed mutation that handles streak updates based on the last played timestamp.
  • Added a new internalMutation to reset the streaks of inactive users.

Reminder:

To test these changes locally, you need to run

npx convex dev

to update your backend instance with the newest code.

Let me know if you get an error, and I can help you. It is because the user schema changed, so you have to do a hack to get it updated.

Screenshot 2025-04-07 at 5 06 42 PM

Copy link
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.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

convex/users.ts:175

  • Ensure that incrementing the streak when the time difference is exactly 24 hours is the intended behavior, as this boundary condition could lead to an unexpected streak increment.
+      if (timeSinceLastPlay <= 24 * 60 * 60 * 1000) {

app/(gameplay)/game/_context/GameContext.tsx:145

  • [nitpick] Consider awaiting the updateStreak mutation to handle potential errors or explicitly document that its fire-and-forget usage is intentional.
updateStreak({ clerkId: user.clerkId });

Copy link
Collaborator

@divinewton divinewton left a comment

Choose a reason for hiding this comment

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

Amazing 😍

@divinewton divinewton merged commit 5b0eed3 into main Apr 8, 2025
4 checks passed
@divinewton divinewton deleted the streak-system branch April 8, 2025 00:44
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.

3 participants