Skip to content

feat(backend): implement user preferences on signup and public predictions list with unit tests#1215

Merged
Olowodarey merged 2 commits into
Arena1X:mainfrom
testersweb0-bug:feature/backend-issue-resolutions
Jun 24, 2026
Merged

feat(backend): implement user preferences on signup and public predictions list with unit tests#1215
Olowodarey merged 2 commits into
Arena1X:mainfrom
testersweb0-bug:feature/backend-issue-resolutions

Conversation

@testersweb0-bug

Copy link
Copy Markdown
Contributor

Summary of Changes

This PR addresses four assigned issues regarding automatic preference creation, short-circuit validation checks, public prediction lists, and leaderboard ordering switch tests.

1. Automatic UserPreferences Creation (#1087)

  • Goal: Automatically initialize a UserPreferences row when a new user signs up.
  • Implemented:
    • Added UserPreferences to TypeOrmModule.forFeature in AuthModule.
    • In AuthService.verifySignature(), we check if the user is a newly created record and create/save a corresponding default UserPreferences record.
    • Implemented logic to ensure existing users do not receive duplicate preference records.
    • Added unit tests in auth.service.spec.ts asserting both preference creation for new users and non-creation/idempotency for existing users.

2. Predictions Short-Circuit Verification (#1088)

  • Goal: Prevent Soroban on-chain prediction locks when a local market validation fails.
  • Implemented:
    • Added assertions to predictions.service.spec.ts verifying that SorobanService.submitPrediction is never called when market validation fails (e.g., market is resolved, cancelled, expired, not found, or outcome is invalid).

3. Public Route for Predictions by Market ID (#1094)

  • Goal: Add GET /predictions/market/:marketId public route for anonymized, paginated prediction data.
  • Implemented:
    • Created ListMarketPredictionsDto for page/limit query validation.
    • Implemented findByMarket on PredictionsService, mapping and returning paginated predictions with user details completely removed (anonymized). Returns an empty list if the market does not exist (not a 404).
    • Added public GET /predictions/market/:marketId route to PredictionsController.
    • Added comprehensive unit tests in predictions.service.spec.ts.

4. Leaderboard Order Switch Verification (#1089)

  • Goal: Confirm sorting paths in LeaderboardService tests.
  • Verified:
    • Verified that tests in leaderboard.service.spec.ts already correctly test global sorting by reputation_score and seasonal sorting by season_points, as well as validating that accuracy rate defaults to "0.0" when total_predictions is 0.

Verification & Testing

Ran the following tests to verify correctness:

npm test src/auth/auth.service.spec.ts src/predictions/predictions.service.spec.ts src/leaderboard/leaderboard.service.spec.ts

Closes #1089
Closes #1094
Closes #1088
Closes #1087

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
insight-arena-4rll Ready Ready Preview, Comment Jun 24, 2026 5:16pm

@drips-wave

drips-wave Bot commented Jun 24, 2026

Copy link
Copy Markdown

@testersweb0-bug Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Olowodarey Olowodarey merged commit 443763f into Arena1X:main Jun 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment