Fix issue in handle_get_user_music_api_request for Chunithm where songs would not always return all scores #92

Merged
Hay1tsme merged 1 commits from Kumubou/artemis:develop into develop 2024-01-09 01:20:46 +00:00
Contributor

Originally reported in issue #91:

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:

try:        
    while song_list[-1]["userMusicDetailList"][0]["musicId"] == music_detail[x + 1]["musicId"]:
        music = music_detail[x + 1]._asdict()
        music.pop("user")
        music.pop("id")
        song_list[-1]["userMusicDetailList"].append(music)
        song_list[-1]["length"] += 1
        x += 1
except IndexError:
    pass

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:

        for songIdx in range(len(song_list)): 
            for recordIdx in range(x+1, len(music_detail)):
                if song_list[songIdx]["userMusicDetailList"][0]["musicId"] == music_detail[recordIdx]["musicId"]:
                    music = music_detail[recordIdx]._asdict()
                    music.pop("user")
                    music.pop("id")
                    song_list[songIdx]["userMusicDetailList"].append(music)
                    song_list[songIdx]["length"] += 1

I haven't tested this beyond my local profile and a couple of test profiles, so this may still lead to things exploding.

This pull request is to have that change applied.

Originally reported in issue #91: 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: ``` try: while song_list[-1]["userMusicDetailList"][0]["musicId"] == music_detail[x + 1]["musicId"]: music = music_detail[x + 1]._asdict() music.pop("user") music.pop("id") song_list[-1]["userMusicDetailList"].append(music) song_list[-1]["length"] += 1 x += 1 except IndexError: pass ``` 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: ``` for songIdx in range(len(song_list)): for recordIdx in range(x+1, len(music_detail)): if song_list[songIdx]["userMusicDetailList"][0]["musicId"] == music_detail[recordIdx]["musicId"]: music = music_detail[recordIdx]._asdict() music.pop("user") music.pop("id") song_list[songIdx]["userMusicDetailList"].append(music) song_list[songIdx]["length"] += 1 ``` I haven't tested this beyond my local profile and a couple of test profiles, so this may still lead to things exploding. This pull request is to have that change applied.
Kumubou added 1 commit 2024-01-03 22:13:48 +00:00
Kumubou changed title from Fix issue in handle_get_user_music_api_request where songs would not always return all scores to Fix issue in handle_get_user_music_api_request for Chunithm where songs would not always return all scores 2024-01-03 22:17:45 +00:00
Collaborator

Hi Kumubou

I should be able to have this tested by the end of the week if not earlier, I'll see if this fixes one of the issue i've noticed with scores that randomly disappeared and reappeared after a card-in.

Thanks

Hi Kumubou I should be able to have this tested by the end of the week if not earlier, I'll see if this fixes one of the issue i've noticed with scores that randomly disappeared and reappeared after a card-in. Thanks
Hay1tsme added the
bug
chuni
testing
labels 2024-01-08 21:40:03 +00:00
Owner

PR tested working, merging!

PR tested working, merging!
Hay1tsme merged commit c9dfbc77c4 into develop 2024-01-09 01:20:46 +00:00
Kumubou deleted branch develop 2024-04-16 23:59:58 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Hay1tsme/artemis#92
No description provided.