mirror of https://github.com/hykilpikonna/AquaDX
[M] Rename database fields
parent
abc21badb1
commit
26a72244c0
|
@ -109,7 +109,6 @@ abstract class GameApiController<T : IGenericUserData>(name: String, userDataCla
|
||||||
|
|
||||||
return GenericGameSummary(
|
return GenericGameSummary(
|
||||||
name = user.userName,
|
name = user.userName,
|
||||||
iconId = user.iconId,
|
|
||||||
aquaUser = card.aquaUser?.publicFields,
|
aquaUser = card.aquaUser?.publicFields,
|
||||||
serverRank = userDataRepo.getRanking(user.playerRating),
|
serverRank = userDataRepo.getRanking(user.playerRating),
|
||||||
accuracy = plays.acc(),
|
accuracy = plays.acc(),
|
||||||
|
|
|
@ -25,7 +25,6 @@ data class RankCount(val name: String, val count: Int)
|
||||||
|
|
||||||
data class GenericGameSummary(
|
data class GenericGameSummary(
|
||||||
val name: String,
|
val name: String,
|
||||||
val iconId: Int,
|
|
||||||
|
|
||||||
val aquaUser: Map<String, Any?>?,
|
val aquaUser: Map<String, Any?>?,
|
||||||
|
|
||||||
|
|
|
@ -346,11 +346,6 @@ public class UserData implements Serializable, IGenericUserData {
|
||||||
@Transient
|
@Transient
|
||||||
private UserEmoney userEmoney;
|
private UserEmoney userEmoney;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIconId() {
|
|
||||||
return characterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTotalScore() {
|
public long getTotalScore() {
|
||||||
return totalHiScore;
|
return totalHiScore;
|
||||||
|
|
|
@ -6,8 +6,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||||
import icu.samnyan.aqua.net.games.BaseEntity
|
import icu.samnyan.aqua.net.games.BaseEntity
|
||||||
import icu.samnyan.aqua.net.games.IGenericUserData
|
import icu.samnyan.aqua.net.games.IGenericUserData
|
||||||
import icu.samnyan.aqua.sega.general.model.Card
|
|
||||||
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
||||||
|
import icu.samnyan.aqua.sega.general.model.Card
|
||||||
import icu.samnyan.aqua.sega.util.jackson.AccessCodeSerializer
|
import icu.samnyan.aqua.sega.util.jackson.AccessCodeSerializer
|
||||||
import jakarta.persistence.*
|
import jakarta.persistence.*
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ class Mai2UserDetail(
|
||||||
@JsonInclude
|
@JsonInclude
|
||||||
@Transient
|
@Transient
|
||||||
var nameplateId: Int = 0,
|
var nameplateId: Int = 0,
|
||||||
override var iconId: Int = 0,
|
var iconId: Int = 0,
|
||||||
|
|
||||||
@JsonInclude
|
@JsonInclude
|
||||||
@Transient
|
@Transient
|
||||||
|
|
|
@ -158,11 +158,6 @@ public class UserData implements Serializable, IGenericUserData {
|
||||||
|
|
||||||
private int lastEmoneyBrand;
|
private int lastEmoneyBrand;
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getIconId() {
|
|
||||||
return characterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getTotalScore() {
|
public long getTotalScore() {
|
||||||
return sumTechHighScore;
|
return sumTechHighScore;
|
||||||
|
|
|
@ -291,25 +291,25 @@ fun WaccaServer.init() {
|
||||||
addItems(items as List<List<Int>>, u, itmGrp(u))
|
addItems(items as List<List<Int>>, u, itmGrp(u))
|
||||||
|
|
||||||
// Upsert playlog
|
// Upsert playlog
|
||||||
val song = WcUserPlayLog.parse(details as List<*>)
|
val pl = WcUserPlayLog.parse(details as List<*>)
|
||||||
rp.playLog.save(song.apply { user = u })
|
rp.playLog.save(pl.apply { user = u })
|
||||||
|
|
||||||
// Update best record
|
// Update best record
|
||||||
val best = rp.bestScore.save((rp.bestScore.findByUserAndSongIdAndDifficulty(u, song.songId, song.difficulty)
|
val best = rp.bestScore.save((rp.bestScore.findByUserAndMusicIdAndLevel(u, pl.musicId, pl.level)
|
||||||
?: WcUserScore().apply { user = u; songId = song.songId; difficulty = song.difficulty }).apply {
|
?: WcUserScore().apply { user = u; musicId = pl.musicId; level = pl.level }).apply {
|
||||||
|
|
||||||
grades[WaccaGrades.valueMap[song.grade]?.ordinal ?: (400 - "Grade ${song.grade} invalid")]++
|
grades[WaccaGrades.valueMap[pl.grade]?.ordinal ?: (400 - "Grade ${pl.grade} invalid")]++
|
||||||
clears = clears.zip(song.clears()) { a, b -> a + b }.toMutableList()
|
clears = clears.zip(pl.clears()) { a, b -> a + b }.toMutableList()
|
||||||
score = max(score, song.score)
|
achievement = max(achievement, pl.achievement)
|
||||||
bestCombo = max(bestCombo, song.maxCombo)
|
bestCombo = max(bestCombo, pl.maxCombo)
|
||||||
lowestMissCt = min(lowestMissCt, song.judgements[3])
|
lowestMissCt = min(lowestMissCt, pl.judgements[3])
|
||||||
rating = waccaRating(score, song.level)
|
rating = waccaRating(achievement, pl.levelConst)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Re-calculate user total score
|
// Re-calculate user total score
|
||||||
rp.user.save(u.apply { totalScore = rp.bestScore.sumScoreByUser(u) })
|
rp.user.save(u.apply { totalScore = rp.bestScore.sumScoreByUser(u) })
|
||||||
|
|
||||||
ls(best.lsMusicUpdate(), ls(song.songId, best.clears[0]), "seasonalInfo" - (1..11).map { 0 }, "ranking" - empty)
|
ls(best.lsMusicUpdate(), ls(pl.musicId, best.clears[0]), "seasonalInfo" - (1..11).map { 0 }, "ranking" - empty)
|
||||||
}
|
}
|
||||||
"user/music/UpdateCoop" redirect "user/music/update"
|
"user/music/UpdateCoop" redirect "user/music/update"
|
||||||
"user/music/UpdateVersus" redirect "user/music/update"
|
"user/music/UpdateVersus" redirect "user/music/update"
|
||||||
|
@ -341,7 +341,7 @@ fun WaccaServer.init() {
|
||||||
|
|
||||||
// Update best record
|
// Update best record
|
||||||
(songs as List<List<Any>>).forEach { (songId, diff, newRating) ->
|
(songs as List<List<Any>>).forEach { (songId, diff, newRating) ->
|
||||||
val best = rp.bestScore.findByUserAndSongIdAndDifficulty(u, songId.int(), diff.int()) ?: return@forEach
|
val best = rp.bestScore.findByUserAndMusicIdAndLevel(u, songId.int(), diff.int()) ?: return@forEach
|
||||||
best.rating = newRating.int()
|
best.rating = newRating.int()
|
||||||
rp.bestScore.save(best)
|
rp.bestScore.save(best)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package icu.samnyan.aqua.sega.wacca.model.db
|
package icu.samnyan.aqua.sega.wacca.model.db
|
||||||
|
|
||||||
|
import icu.samnyan.aqua.net.games.GenericPlaylogRepo
|
||||||
import jakarta.transaction.Transactional
|
import jakarta.transaction.Transactional
|
||||||
import org.springframework.data.jpa.repository.JpaRepository
|
import org.springframework.data.jpa.repository.JpaRepository
|
||||||
import org.springframework.data.jpa.repository.Query
|
import org.springframework.data.jpa.repository.Query
|
||||||
|
@ -31,11 +32,11 @@ interface WcUserItemRepo : IWaccaUserLinked<WcUserItem> {
|
||||||
fun findByUserAndItemIdAndType(user: WaccaUser, itemId: Int, type: Int): WcUserItem?
|
fun findByUserAndItemIdAndType(user: WaccaUser, itemId: Int, type: Int): WcUserItem?
|
||||||
}
|
}
|
||||||
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore> {
|
interface WcUserBestScoreRepo : IWaccaUserLinked<WcUserScore> {
|
||||||
fun findByUserAndSongIdAndDifficulty(user: WaccaUser, songId: Int, difficulty: Int): WcUserScore?
|
fun findByUserAndMusicIdAndLevel(user: WaccaUser, songId: Int, level: Int): WcUserScore?
|
||||||
@Query("SELECT SUM(score) FROM WcUserScore WHERE user = :user")
|
@Query("SELECT SUM(achievement) FROM WcUserScore WHERE user = :user")
|
||||||
fun sumScoreByUser(user: WaccaUser): Long
|
fun sumScoreByUser(user: WaccaUser): Long
|
||||||
}
|
}
|
||||||
interface WcUserPlayLogRepo : IWaccaUserLinked<WcUserPlayLog>
|
interface WcUserPlayLogRepo : IWaccaUserLinked<WcUserPlayLog>, GenericPlaylogRepo<WcUserPlayLog>
|
||||||
interface WcUserStageUpRepo : IWaccaUserLinked<WcUserStageUp>
|
interface WcUserStageUpRepo : IWaccaUserLinked<WcUserStageUp>
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
|
|
@ -3,6 +3,7 @@ package icu.samnyan.aqua.sega.wacca.model.db
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||||
import ext.*
|
import ext.*
|
||||||
import icu.samnyan.aqua.net.games.BaseEntity
|
import icu.samnyan.aqua.net.games.BaseEntity
|
||||||
|
import icu.samnyan.aqua.net.games.IGenericGamePlaylog
|
||||||
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
import icu.samnyan.aqua.sega.general.IntegerListConverter
|
||||||
import icu.samnyan.aqua.sega.wacca.WaccaItemType
|
import icu.samnyan.aqua.sega.wacca.WaccaItemType
|
||||||
import icu.samnyan.aqua.sega.wacca.WaccaItemType.*
|
import icu.samnyan.aqua.sega.wacca.WaccaItemType.*
|
||||||
|
@ -90,11 +91,11 @@ class WcUserItem(
|
||||||
infix fun isType(t: WaccaItemType) = type == t()
|
infix fun isType(t: WaccaItemType) = type == t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity @Table(name = "wacca_user_score", uniqueConstraints = [UC("", ["user_id", "song_id", "chart_id"])])
|
@Entity @Table(name = "wacca_user_score", uniqueConstraints = [UC("", ["user_id", "music_id", "level"])])
|
||||||
class WcUserScore : WaccaUserEntity() {
|
class WcUserScore : WaccaUserEntity() {
|
||||||
var songId = 0
|
var musicId = 0
|
||||||
var difficulty = 0 // aka difficulty
|
var level = 0 // aka difficulty
|
||||||
var score = 0
|
var achievement = 0
|
||||||
|
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var clears: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0) // Played, Clear, Full Combo, Missless, All Marv
|
var clears: MutableList<Int> = mutableListOf(0, 0, 0, 0, 0) // Played, Clear, Full Combo, Missless, All Marv
|
||||||
|
@ -105,37 +106,39 @@ class WcUserScore : WaccaUserEntity() {
|
||||||
var lowestMissCt = Int.MAX_VALUE
|
var lowestMissCt = Int.MAX_VALUE
|
||||||
var rating = 0
|
var rating = 0
|
||||||
|
|
||||||
fun ls() = ls(songId, difficulty, clears, clears, grades, score, bestCombo, lowestMissCt, 1, rating)
|
fun ls() = ls(musicId, level, clears, clears, grades, achievement, bestCombo, lowestMissCt, 1, rating)
|
||||||
fun lsMusicUpdate() = ls(songId, difficulty, clears, clears, grades, score, lowestMissCt, 0, 1, rating)
|
fun lsMusicUpdate() = ls(musicId, level, clears, clears, grades, achievement, lowestMissCt, 0, 1, rating)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity @Table(name = "wacca_user_playlog", uniqueConstraints = [UC("", ["user_id", "song_id", "chart_id", "date_scored"])])
|
@Entity @Table(name = "wacca_user_playlog", uniqueConstraints = [UC("", ["user_id", "music_id", "level", "user_play_date"])])
|
||||||
class WcUserPlayLog : WaccaUserEntity() {
|
class WcUserPlayLog : WaccaUserEntity(), IGenericGamePlaylog {
|
||||||
var songId = 0
|
override var musicId = 0
|
||||||
var difficulty = 0
|
override var level = 0
|
||||||
var level = 0.0
|
var levelConst = 0.0
|
||||||
var score = 0
|
override var achievement = 0
|
||||||
@Convert(converter = IntegerListConverter::class)
|
@Convert(converter = IntegerListConverter::class)
|
||||||
var judgements: MutableList<Int> = mutableListOf(0, 0, 0, 0) // Marv, Great, Good, Miss
|
var judgements: MutableList<Int> = mutableListOf(0, 0, 0, 0) // Marv, Great, Good, Miss
|
||||||
var maxCombo = 0
|
override var maxCombo = 0
|
||||||
var grade = 0
|
var grade = 0
|
||||||
var clear = false
|
var isClear = false
|
||||||
var missless = false
|
var isMissless = false
|
||||||
var fullCombo = false
|
override var isFullCombo = false
|
||||||
var allMarv = false
|
override var isAllPerfect = false
|
||||||
var giveUp = false
|
var giveUp = false
|
||||||
var skillPt = 0
|
var skillPt = 0
|
||||||
var fastCt = 0
|
var fastCt = 0
|
||||||
var lateCt = 0
|
var lateCt = 0
|
||||||
var newRecord = false
|
var newRecord = false
|
||||||
|
override var beforeRating = 0
|
||||||
|
override var afterRating = 0
|
||||||
|
|
||||||
@Temporal(TemporalType.TIMESTAMP)
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
var dateScored = Date()
|
override var userPlayDate = Date()
|
||||||
|
|
||||||
fun clears() = ls(1, +clear, +fullCombo, +missless, +allMarv)
|
fun clears() = ls(1, +isClear, +isFullCombo, +isMissless, +isAllPerfect)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val keys = ls("songId", "difficulty", "level", "score", "judgements", "maxCombo", "grade", "clear", "missless", "fullCombo", "allMarv", "giveUp", "skillPt", "fastCt", "lateCt", "newRecord")
|
val keys = ls("musicId", "level", "levelConst", "achievement", "judgements", "maxCombo", "grade", "clear", "missless", "isFullCombo", "isAllPerfect", "giveUp", "skillPt", "fastCt", "lateCt", "newRecord")
|
||||||
fun parse(l: List<*>) = JACKSON.parse<WcUserPlayLog>(keys.zip(l).toMap())
|
fun parse(l: List<*>) = JACKSON.parse<WcUserPlayLog>(keys.zip(l).toMap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,25 +126,27 @@ create table wacca_user_playlog
|
||||||
id bigint auto_increment
|
id bigint auto_increment
|
||||||
primary key,
|
primary key,
|
||||||
user_id bigint not null,
|
user_id bigint not null,
|
||||||
song_id int not null,
|
music_id int not null,
|
||||||
difficulty int not null,
|
level int not null,
|
||||||
score int not null,
|
level_const double not null,
|
||||||
|
achievement int not null,
|
||||||
grade int not null,
|
grade int not null,
|
||||||
max_combo int not null,
|
max_combo int not null,
|
||||||
fast_ct int not null,
|
fast_ct int not null,
|
||||||
late_ct int not null,
|
late_ct int not null,
|
||||||
all_marv bit not null,
|
is_clear bit not null,
|
||||||
full_combo bit not null,
|
is_missless bit not null,
|
||||||
|
is_full_combo bit not null,
|
||||||
|
is_all_perfect bit not null,
|
||||||
give_up bit not null,
|
give_up bit not null,
|
||||||
judgements varchar(255) not null,
|
judgements varchar(255) not null,
|
||||||
level double not null,
|
|
||||||
missless bit not null,
|
|
||||||
new_record bit not null,
|
new_record bit not null,
|
||||||
skill_pt int not null,
|
skill_pt int not null,
|
||||||
clear bit not null,
|
user_play_date datetime not null,
|
||||||
date_scored datetime not null,
|
after_rating int not null,
|
||||||
|
before_rating int not null,
|
||||||
constraint wacca_user_playlog_unique
|
constraint wacca_user_playlog_unique
|
||||||
unique (user_id, song_id, difficulty, date_scored),
|
unique (user_id, music_id, level, user_play_date),
|
||||||
constraint fku_wacca_user_playlog
|
constraint fku_wacca_user_playlog
|
||||||
foreign key (user_id) references wacca_user (id)
|
foreign key (user_id) references wacca_user (id)
|
||||||
on update cascade on delete cascade
|
on update cascade on delete cascade
|
||||||
|
@ -155,16 +157,16 @@ create table wacca_user_score
|
||||||
id bigint auto_increment
|
id bigint auto_increment
|
||||||
primary key,
|
primary key,
|
||||||
user_id bigint not null,
|
user_id bigint not null,
|
||||||
song_id int not null,
|
music_id int not null,
|
||||||
difficulty int not null,
|
level int not null,
|
||||||
score int not null,
|
achievement int not null,
|
||||||
best_combo int not null,
|
best_combo int not null,
|
||||||
lowest_miss_ct int not null,
|
lowest_miss_ct int not null,
|
||||||
rating int not null,
|
rating int not null,
|
||||||
clears varchar(255) not null,
|
clears varchar(255) not null,
|
||||||
grades varchar(255) not null,
|
grades varchar(255) not null,
|
||||||
constraint wacca_user_score_unique
|
constraint wacca_user_score_unique
|
||||||
unique (user_id, song_id, difficulty),
|
unique (user_id, music_id, level),
|
||||||
constraint fku_wacca_user_score
|
constraint fku_wacca_user_score
|
||||||
foreign key (user_id) references wacca_user (id)
|
foreign key (user_id) references wacca_user (id)
|
||||||
on update cascade on delete cascade
|
on update cascade on delete cascade
|
||||||
|
|
Loading…
Reference in New Issue