fix: ongeki technical challenge records stored and deduped by chart difficulty

This commit is contained in:
asterisk727
2026-09-05 15:38:53 +09:00
parent a95a1efb0d
commit a12ec07917
4 changed files with 26 additions and 4 deletions
@@ -58,7 +58,8 @@ interface OgkUserEventMusicRepo : OngekiUserLinked<UserEventMusic> {
userData: UserData,
eventId: Int,
type: Int,
musicId: Int
musicId: Int,
level: Int
): UserEventMusic?
}
@@ -197,8 +197,9 @@ fun OngekiController.initUpsertAll() {
// UserEventMusicList
userEventMusicList?.let { list ->
db.eventMusic.saveAll(list.distinctBy { it.eventId to it.type to it.musicId }.mapApply {
id = db.eventMusic.findByUserAndEventIdAndTypeAndMusicId(u, eventId, type, musicId)?.id ?: 0 }) }
db.eventMusic.saveAll(list.distinctBy { it.eventId to it.type to it.musicId to it.level }.mapApply {
id = db.eventMusic.findByUserAndEventIdAndTypeAndMusicId(u, eventId, type, musicId, level)?.id ?: 0
}) }
// UserTechEventList
userTechEventList?.let { list ->
@@ -197,7 +197,10 @@ class UserDeck : OngekiUserEntity() {
}
@Entity(name = "OngekiUserEventMusic")
@Table(name = "ongeki_user_event_music")
@Table(
name = "ongeki_user_event_music",
uniqueConstraints = [UniqueConstraint(columnNames = ["user_id", "event_id", "type", "music_id", "level"])]
)
class UserEventMusic : OngekiUserEntity() {
var eventId = 0
var type = 0
@@ -0,0 +1,17 @@
-- allow separate Technical Challenge records for each chart difficulty
-- drop the old constraint and dedupe with the new constraint just in case again
ALTER TABLE ongeki_user_event_music
DROP INDEX UKo5PU3BgZeTKB8SNykq9U7xjfshp;
DELETE FROM ongeki_user_event_music
WHERE id NOT IN (
SELECT id
FROM (
SELECT MAX(id) AS id
FROM ongeki_user_event_music
GROUP BY user_id, event_id, type, music_id, level
) AS rows_to_keep
);
ALTER TABLE ongeki_user_event_music
ADD UNIQUE KEY uniq_ongeki_user_event_music (user_id, event_id, type, music_id, level);