-
Notifications
You must be signed in to change notification settings - Fork 92
Implemented functionality to calculate all local scores using Realm #213
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
62294c9
8ec4ed2
1c81765
ce15637
ed1d7f6
eef465b
dd2123e
9acd859
5f912bf
a2b4f3b
6d082ac
417c6de
2b28193
dc560e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| using PerformanceCalculatorGUI.Configuration; | ||
| using System.IO; | ||
| using osu.Framework.Platform; | ||
| using osu.Game.Screens.Play; | ||
|
|
||
| namespace PerformanceCalculatorGUI.Screens | ||
| { | ||
|
|
@@ -411,9 +412,24 @@ private void calculateProfileFromLazer(string username) | |
| { | ||
| Schedule(() => loadingLayer.Text.Value = "Getting user data..."); | ||
|
|
||
| var player = await apiManager.GetJsonFromApi<APIUser>($"users/{username}/{ruleset.Value.ShortName}"); | ||
| APIUser player = null; | ||
|
|
||
| try | ||
| { | ||
| player = await apiManager.GetJsonFromApi<APIUser>($"users/{username}/{ruleset.Value.ShortName}"); | ||
|
|
||
| currentUserNicknames = [player.Username, .. player.PreviousUsernames, player.Id.ToString()]; | ||
|
|
||
| currentUserNicknames = [player.Username, .. player.PreviousUsernames, player.Id.ToString()]; | ||
| } catch { | ||
| notificationDisplay.Display(new Notification("Unable to find player on the servers, using local name...")); | ||
|
|
||
| player = new APIUser | ||
| { | ||
| Username = username | ||
| }; | ||
|
|
||
| currentUserNicknames = [username]; | ||
| } | ||
|
|
||
| Schedule(() => | ||
| { | ||
|
|
@@ -430,11 +446,8 @@ private void calculateProfileFromLazer(string username) | |
|
|
||
| if (token.IsCancellationRequested) | ||
| return; | ||
|
|
||
| var plays = new List<ProfileScore>(); | ||
|
|
||
| var rulesetInstance = ruleset.Value.CreateInstance(); | ||
|
|
||
| var lazerPath = configManager.GetBindable<string>(Settings.LazerFolderPath).Value; | ||
|
|
||
| if (lazerPath == string.Empty) | ||
|
|
@@ -444,6 +457,7 @@ private void calculateProfileFromLazer(string username) | |
| } | ||
|
|
||
| var storage = gameHost.GetStorage(lazerPath); | ||
|
|
||
| var realmAccess = new RealmAccess(storage, @"client.realm"); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be fine as long as it's constrained to a single thread. If you're passing the realm or objects retrieved within it that are not
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It already crashes on someone's linux machine because of cross-thread access, I think it'd just be safer to use it through safeguards instead of hoping that TPL wouldn't do something funny |
||
|
|
||
| var realmScores = getRealmScores(realmAccess); | ||
|
|
@@ -472,7 +486,7 @@ private void calculateProfileFromLazer(string username) | |
| if (token.IsCancellationRequested) | ||
| return; | ||
|
|
||
| Schedule(() => loadingLayer.Text.Value = $"Calculating {player.Username}'s scores... {currentScoresCount} / {totalScoresCount}"); | ||
| Schedule(() => loadingLayer.Text.Value = $"Calculating {username}'s scores... {currentScoresCount} / {totalScoresCount}"); | ||
|
|
||
| if (score.BeatmapInfo == null) | ||
| continue; | ||
|
|
@@ -568,7 +582,7 @@ private List<List<ScoreInfo>> getRealmScores(RealmAccess realm) | |
|
|
||
| Schedule(() => loadingLayer.Text.Value = "Filtering scores..."); | ||
|
|
||
| realmScores.RemoveAll(x => !currentUserNicknames.Contains(x.User.Username) // Wrong username | ||
| realmScores.RemoveAll(x => !currentUserNicknames.Any(nickname => nickname.Equals(x.User.Username, StringComparison.OrdinalIgnoreCase)) // Wrong username | ||
| || x.BeatmapInfo == null // No map for score | ||
| || x.Passed == false || x.Rank == ScoreRank.F // Failed score | ||
| || x.Ruleset.OnlineID != ruleset.Value.OnlineID // Incorrect ruleset | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools should never use lazer's database directly - please copy to a local directory and use that instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then please add the least add buttons to copy lazers data into a local copy and be able to sync it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't, it should be syncronized automatically at the start of profile calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh thats an option too, but why should it be cloned instead of accessing Lazer directly in the first place? Issues if Lazer is running at the same time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copying 30+ gigs of data? sounds very bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either that or maybe have the user select the client.db?
Furthermore, I wonder if you'd be better off splitting into two processes:
You could implement (1) as a CLI command that writes the DB to an output path.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good way to make copied client.realm to contain ONLY replay files
not only this will be more convenient - it will be also faster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faster how? You said it's a 50MB file? That takes 2 seconds on a 2000s era HDD, and is practically instantaneous on anything faster.
I suggest you don't go pre-optimising.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not about copying
The first 28 seconds of 3 minutes calculation was spent to collect all scores from the database, what is quite big portion of the time
Source:
https://www.youtube.com/watch?v=KEYa7Y-UJCw
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a problem with the structure of your code, because you're using
Detach(). You should restructure so you don't have to do that, such as using theLive<>class or otherwise.