Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature implement update result endpoint #133 #169

Conversation

LaGodxy
Copy link
Contributor

@LaGodxy LaGodxy commented Feb 25, 2025

Closes-#133

Pull Request Description

Overview

This PR introduces enhancements to the game results tracking functionality by implementing an update endpoint to manage user performance metrics and a delete endpoint for removing game results. The changes ensure that metrics like times played, current streak, maximum streak, wins, and win percentage are accurately tracked and updated after each game play. Additionally, dependency injection issues in the Result module have been resolved.

Key Changes

1. Update Result Endpoint

  • New DTO:
    A dedicated UpdateResultDto has been created to accept only the necessary fields:

    • userId (UUID): Ensures the result update targets the correct user.
    • won (boolean): Indicates whether the game was won.
  • Controller Update:
    The PATCH endpoint now uses the route PATCH /results/:userId and leverages the new DTO for validating incoming data.

  • Service Logic:
    The updateResult method in ResultService now:

    • Increments timesPlayed for every game played.
    • Updates currentStreak (increments if won, resets if lost).
    • Updates maxStreak when the current streak exceeds the previous maximum.
    • Increments the wins counter and recalculates winPercentage using (wins / timesPlayed) * 100.

2. Entity Enhancements

  • New Metrics Fields:
    The Result entity has been updated with the following new columns:

    • timesPlayed (integer, default: 0)
    • currentStreak (integer, default: 0)
    • maxStreak (integer, default: 0)
    • wins (integer, default: 0)
    • winPercentage (float, default: 0)
  • Feedback Field Update:
    The feedback column now uses a simple-array type to clearly store an array of strings.

3. Delete Endpoint Implementation

  • Controller:
    Updated the delete endpoint in the ResultController to use ParseIntPipe for type conversion

Copy link

vercel bot commented Feb 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
de-wordle ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 0:41am

@BigBen-7 BigBen-7 merged commit 42315ea into Lead-Studios:main Feb 26, 2025
4 checks passed
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