Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Danielsl4/TFG_DAM_2526_Consulta2/llms.txt

Use this file to discover all available pages before exploring further.

The prediction system lets registered users forecast the result of every upcoming match. Pick the home win, a draw, or the away win before the match starts, and earn a point for each correct prediction. Points accumulate over the season and are ranked on a public leaderboard, so every match is a chance to climb the table.

How voting works

Before a match begins, each match card shows three prediction buttons:
  • Local — home team wins
  • Empate — the match ends in a draw
  • Visitante — away team wins
Votes are stored in the match_votes table, one row per user per match. Submitting a new prediction before kick-off replaces your previous vote automatically, so you can change your mind any number of times until the match status moves to en_curso. Once a match is in progress or has finished, the vote buttons are hidden. The voting bar remains visible, showing the percentage breakdown of all predictions cast.
Voting is only available for authenticated users. Guest visitors can see the current vote distribution on each match card, but cannot submit a prediction.

Earning points

When a referee marks a match as finalizado, the system determines the real outcome:
  • local — home team scored more goals
  • empate — both teams scored the same number of goals
  • visitante — away team scored more goals
Every user whose vote matches the real outcome is awarded 1 point. Points are written to the user_points table, keyed to the user and the current season. The match’s match_votes rows are also updated with points_awarded = 1 for correct predictions, giving you a full history of which calls you got right.

Leaderboard

The season leaderboard ranks all registered users by their total prediction points for the selected season. Users with zero votes or zero correct predictions still appear on the board with 0 points. Ties are broken alphabetically by username. The top 10 users are shown by default. You can also view your own stats — total points, current rank, and a history of your last 20 predictions with the real result alongside each one — in your profile area.

Restrictions

Not every match is open for voting. A match must satisfy all of the following conditions before the vote buttons appear:
  • Status is pendiente — the match has not started yet
  • Both home_team_id and away_team_id are confirmed — placeholder teams are not votable
  • The user is authenticated
Attempting to vote on a match that does not meet these conditions returns an error. One vote per user per match is enforced at the database level with a unique constraint on (match_id, user_id).

Submitting a prediction

1

Navigate to a match

Open the match calendar and select any upcoming match with a status of pendiente and both teams confirmed.
2

Click your prediction

Tap Local, Empate, or Visitante on the match card. Your choice is saved immediately and highlighted to confirm the vote.
3

See live vote stats

After voting, the prediction bar updates to show the current distribution across all users. You can change your vote at any time before the match starts.
4

Earn points when the match finalizes

Once the referee marks the match as finished, the system checks your prediction against the real result. A correct call awards you 1 point, visible on the leaderboard and in your personal stats.

Build docs developers (and LLMs) love