You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"⚠️Please ensure you read and follow the contribution guidelines. Failure to do so may result in your contribution being rejected." "⚠️Please include an expected delivery date in your application. Failure to do so may void your application. Also, test your code thoroughly to ensure it works as expected before creating a PR."
Feature:
Description
We need an endpoint to create a result entry for users in the Result Module. This should store key user performance metrics. Change placeholders in the result modules, i.e., entity, DTO, controller, and services:
Times Played
Current Streak
Max Streak
Win Percentage
Additionally, when a new user signs up, a default result entry should be created automatically.
Tasks
1. Create ResultDto for Data Validation
Fields:
userId: string (linked to the user)
timesPlayed: number (default: 0)
currentStreak: number (default: 0)
maxStreak: number (default: 0)
winPercentage: number (default: 0.0)
Use class-validator to enforce correct data types.
2. Implement Create Result Endpoint
POST /results → Creates a new result entry for a user.
Validate the request using ResultDto.
Ensure that a user can only have one result entry.
3. Auto-Create a Result When a User Signs Up
Modify the User Service or Auth Module to:
Call ResultService.createResult(userId) after a successful signup.
Ensure result creation is transactional (user and result must be created together).
4. Implement ResultService Methods
createResult(userId: string)
Check if the user already has a result entry.
If not, create a new one with default values.
Save the result in the database.
5. Handle Errors Gracefully
400 Bad Request → If the result data is invalid.
409 Conflict → If a result already exists for the user.
500 Internal Server Error → If an unexpected error occurs.
Tech Stack
Backend: NestJS
Validation: class-validator
Database: PostgreSQL (or relevant DB)
Authentication: JWT/AuthGuard
Acceptance Criteria
✅ Users have a result entry automatically created upon signup.
✅ The POST /results endpoint allows manual creation if needed (ensuring no duplicates).
✅ Proper validation and error handling are in place.
The text was updated successfully, but these errors were encountered:
"⚠️ Please ensure you read and follow the contribution guidelines. Failure to do so may result in your contribution being rejected."⚠️ Please include an expected delivery date in your application. Failure to do so may void your application. Also, test your code thoroughly to ensure it works as expected before creating a PR."
"
Feature:
Description
We need an endpoint to create a result entry for users in the Result Module. This should store key user performance metrics. Change placeholders in the result modules, i.e., entity, DTO, controller, and services:
Additionally, when a new user signs up, a default result entry should be created automatically.
Tasks
1. Create ResultDto for Data Validation
Fields:
userId
: string (linked to the user)timesPlayed
: number (default: 0)currentStreak
: number (default: 0)maxStreak
: number (default: 0)winPercentage
: number (default: 0.0)Use
class-validator
to enforce correct data types.2. Implement Create Result Endpoint
POST /results
→ Creates a new result entry for a user.ResultDto
.3. Auto-Create a Result When a User Signs Up
Modify the User Service or Auth Module to:
ResultService.createResult(userId)
after a successful signup.4. Implement ResultService Methods
createResult(userId: string)
5. Handle Errors Gracefully
Tech Stack
Acceptance Criteria
✅ Users have a result entry automatically created upon signup.
✅ The
POST /results
endpoint allows manual creation if needed (ensuring no duplicates).✅ Proper validation and error handling are in place.
The text was updated successfully, but these errors were encountered: