Migrate scores to use proper relationships#830
Merged
Slendy merged 17 commits intoLBPUnion:mainfrom Aug 19, 2023
Merged
Conversation
sudokoko
approved these changes
Jul 11, 2023
Member
sudokoko
left a comment
There was a problem hiding this comment.
LGTM, just a few nitpicks and questions
ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs
Outdated
Show resolved
Hide resolved
Zaprit
approved these changes
Jul 14, 2023
Member
Zaprit
left a comment
There was a problem hiding this comment.
Looks good, see my question in the comment though
ProjectLighthouse.Servers.GameServer/Controllers/Resources/ResourcesController.cs
Outdated
Show resolved
Hide resolved
sudokoko
approved these changes
Jul 14, 2023
sudokoko
approved these changes
Aug 17, 2023
Member
sudokoko
left a comment
There was a problem hiding this comment.
Decided to take another look at this since there have been changes since I approved a month ago. Still looks good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The old way scores worked was using players' usernames in a comma-delimited list which has obvious problems like being able to spoof scores because the system ultimately trusts the score uploader. Other problems include different permutations of usernames will create entirely new scores instead of updating old ones.
The migration uses raw SQL because after the migration the entity is no longer compatible and would be complicated to implement with EF as it is now. There is a new feature in NET 8.0 to map raw SQL queries to objects but it doesn't release until November of this year.
Some drawbacks of the new system are that non-existent users are no longer allowed to keep scores. This also means that once a user is deleted, all of their scores will also be deleted. In some cases this is beneficial; for example, if a single user cheated many scores you can remove all of their scores by simply deleting their account.
Since this PR also creates more scores per level since every user gets their own score regardless of the number of players that were in the session, there also needs to be a rework of the score viewer on the website to have pagination and filter by score type but that's outside the scope of this PR.
TODO
In some cases where people have multiple scores under the same level and category will have their highest score selected and kept.