Chunithm - GetUserMusicApi doesn't always return all results when more than 300 songs have scores #91
Labels
No Label
aimedb
bug
chuni
chusan
cxb
database
diva
doc
duplicate
enhancement
frontend
help wanted
idac
idz
invalid
maidx
ongeki
pokken
question
seen
system
testing
wacca
waiting
wip
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Hay1tsme/artemis#91
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Recently noticed that scores saved on my profile for Chunithm Sun Plus on the current development build of Artemis suddenly started disappearing in-game. Looking into the issue further, the song scores were saved in
chuni_score_playlog
andchuni_score_best
and did not look malformed, but for some songs the scores would go missing after logging out and then carding back in. Figuring I might have blown up my profile messing around, I created another one to see if there was something wrong with the game, and scores there saved fine. So I then reassigned all of the score entries in those two tables to that new user... and then the same scores disappeared. Weird. The scores are still in Artemis (and even update properly in the playlog and best tables!) but were not showing up in-game. Poking at the scores, I found that they all did load if I had cut down the list inchuni_score_best
to a smaller number, and then at some point a bunch of scores would just disappear, all at once. Enabled debug logging in the Chunithm module to try to find out where exactly this was going wrong, starting with the smaller subset of scores, basically going in order from 0 to X in the database plus adding a few scores from later IDs that I noticed would go missing:This loaded fine.
This also loaded all of the scores.
This is when scores went missing. It turned out from my testing that the scores would go missing with more than 353 entries in
chuni_score_best
, but that number is a bit of a red herring, as it turns the number to trigger it can vary. I started looking into what songs would miss data, as I did find a pattern to it:chuni_score_best
. For example, one song had rows with IDs 4, 412, 662 and 1005 and the game was only loading the score from the entry in row 4. So playing a new difficulty won't bring back the older scores (they are saved in the database, they just aren't being returned by Artemis).From what I can tell, Chunithm requests the scores in blocks of 300 songs and songs with scores on multiple difficulties in the same "block" of IDs (0-300, 301-600, 601-900) do get returned properly, but not when scores are split across that range.
I think I managed to find the source of the issue, in titles/chuni/base.py -- there's seemingly a block of code that goes over the resulting song list and then insert scores:
Except the current code only looks at the last song in the list, when it really needs to be checking every song, as the entries in
chuni_score_best
are not guaranteed to be in any order (they're IDed as they happen on profiles).I managed to fix this on my local instance by instead iterating over every song and every entry in
chuni_score_best
after the last one checked:I haven't tested this beyond my local profile and a couple of test profiles, so this may still lead to things exploding.
It also looks like other parts of
handle_get_user_music_api_request
could be refactored, as it looks like the part where it iterates infor song in song_list
doesn't seem to do anything anymore except updateSCORE_BUFFER
(and it seems to be adding entries that are already in there from when the song was first added tosong_list
, so it seems completely redundant).Pull request with fix submitted in #92
Hey, thanks for the issue report. I'll look over your PR and see if I can get it merged!
Closing this, as the PR fixing this has been merged.