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

League Points Calculation + Task Scheduling #195

Merged
merged 13 commits into from
Dec 4, 2024

Conversation

GODrums
Copy link
Collaborator

@GODrums GODrums commented Dec 1, 2024

Motivation

Solves tasks 3.2 and 3.3 of #170.

Description

Please checkout the textual description of how leagues are meant work in #170 first.

Summary league details (from #170):

  • according to a player's current league points, they are assigned to exactly one of these leagues: bronze, silver, gold, platinum, diamond
  • the starting rating should be 1000 and every leaderboard cycle increases/decreases a player's rating according to their performance
  • rating changes are calculated according to the following formula:
    rank-formula-latex
    • s: leaderboard score, r: leaderboard ranking, p: player's league points
    • Description: The change in rating is equivalent to a weighted sum of the player's leaderboard score plus a placement bonus minus a point decay based on the player's current points.

This PR includes the fundamental logic for calculating leaderboard leagues:

  • Adds a leaguePoints-attribute to the User, storing the user's current "league" as points.
  • The LeaguePointsCalculationService calculates the ranking point change based on a user's result in the (completed) leaderboard. All details regarding the algorithm/formula are described in Leaderboard leagues #170.
  • The LeaguePointsUpdateTask is a task scheduled at the end of every leaderboard cycle, which initiates the rating change calculation for the finished leaderboard

Testing Instructions

Next to standard reviews, I would also appreciate concept reviews regarding the used algorithm.

  • Change the execution schedule in LeaderboardTaskScheduler such that the task executes instantly (e.g. scheduleWithFixedDelay and Duration.of(1))
  • Run application-server and check calculated values in the console
  • Evaluate yourself if applied rating changes seem reasonable

Checklist

General

  • PR title is clear and descriptive
  • PR description explains the purpose and changes
  • Code follows project coding standards
  • Self-review of the code has been done
  • Changes have been tested locally
  • Screenshots have been attached (if applicable)
  • Documentation has been updated (if applicable)

Server (if applicable)

  • Code is performant and follows best practices
  • No security vulnerabilities introduced
  • Proper error handling has been implemented
  • Added tests for new functionality
  • Changes have been tested in different environments (if applicable)

@GODrums GODrums self-assigned this Dec 1, 2024
@github-actions github-actions bot added application-server size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 1, 2024
@GODrums GODrums added enhancement New feature or request research and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Dec 1, 2024
@GODrums GODrums mentioned this pull request Dec 1, 2024
15 tasks
@github-actions github-actions bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 1, 2024
FelixTJDietrich
FelixTJDietrich previously approved these changes Dec 4, 2024
Copy link
Collaborator

@FelixTJDietrich FelixTJDietrich left a comment

Choose a reason for hiding this comment

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

Other than the one comment this looks good. I thought about if it makes sense to not realize all the merged pull requests in memory, this could technically be done in the database.

…tus/leaderboard/LeaguePointsCalculationService.java
@FelixTJDietrich FelixTJDietrich merged commit 566ae85 into develop Dec 4, 2024
4 of 5 checks passed
@FelixTJDietrich FelixTJDietrich deleted the 170-league-points-calculation-service branch December 4, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
application-server enhancement New feature or request research size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants