Implemented the database schema and models needed to retrieve the information required to rank the users on the leaderboard. Made use of existing model for Points and set up a route to render the leaderboard as well as an API endpoint to retrieve the next users to display on the leaderboard.
Changes Made:
Made a route in the main.py file to render the leaderboard page and send in the top 20 users in terms of total point count, implemented pagination in the query to help display the next set of users for a large user base
Uncommented the user relationship in the Points model to allow for the join query and retrieve user points
Added API endpoint into routes.py file to support dynamic updates on the leaderboard page, returning the next set of users based on their ranking
Next steps/Things to note:
Set up the user ranking based on total points for now, do we want to use a different metric instead (XP from UserProgress model can be used as well, however it is currently set up to indicate the amount of XP needed to progress to the next level)
Implement the pagination feature into the HTML as well, also need to add an AJAX request in the JS to retrieve the next set of users for the leaderboard
Wasn't too sure how to go about further optimizing the performance of the queries to support the frequent updates and retrievals on the points field, could add the "index=True" line to index the points attribute and potentially speed up the queries (faster retrieval but may affect update time?)
In the current JSON response, I only sent in the user name and their point count, we can maybe add some other information to display on the leaderboard as well?
Implemented the database schema and models needed to retrieve the information required to rank the users on the leaderboard. Made use of existing model for Points and set up a route to render the leaderboard as well as an API endpoint to retrieve the next users to display on the leaderboard.
Changes Made:
Next steps/Things to note: