Persist live status and migrate legacy live data
- Add user_live_status to store hi score, hi combo count, and clear count per chart - Expand user_live_goal to persist achieved live_goal_reward_id entries instead of only coarse goal types - Update live reward handling to refresh live status and sync newly achieved live goals on every clear - Return live status and achieved goal ids from stored user data in /api/live/status - Aggregate profile liveCnt from stored user_live_status instead of hardcoded values - Load complete-rank thresholds from live info for goal evaluation - Migrate legacy user_live_record data into user_live_status and backfill achievable live goals on startup Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -268,46 +268,49 @@ func buildRandomLiveList() []liveapischema.RandomLiveList {
|
||||
}
|
||||
}
|
||||
|
||||
func buildNormalLiveStatusList(ids []int) []liveapischema.NormalLiveStatusList {
|
||||
func buildNormalLiveStatusList(ids []int, snapshotMap map[int]session.LiveStatusSnapshot) []liveapischema.NormalLiveStatusList {
|
||||
result := make([]liveapischema.NormalLiveStatusList, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
snapshot := snapshotMap[id]
|
||||
result = append(result, liveapischema.NormalLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
Status: snapshot.Status,
|
||||
HiScore: snapshot.HiScore,
|
||||
HiComboCount: snapshot.HiComboCount,
|
||||
ClearCnt: snapshot.ClearCnt,
|
||||
AchievedGoalIDList: snapshot.AchievedGoalIDList,
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func buildSpecialLiveStatusList(ids []int) []liveapischema.SpecialLiveStatusList {
|
||||
func buildSpecialLiveStatusList(ids []int, snapshotMap map[int]session.LiveStatusSnapshot) []liveapischema.SpecialLiveStatusList {
|
||||
result := make([]liveapischema.SpecialLiveStatusList, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
snapshot := snapshotMap[id]
|
||||
result = append(result, liveapischema.SpecialLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
Status: snapshot.Status,
|
||||
HiScore: snapshot.HiScore,
|
||||
HiComboCount: snapshot.HiComboCount,
|
||||
ClearCnt: snapshot.ClearCnt,
|
||||
AchievedGoalIDList: snapshot.AchievedGoalIDList,
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func buildTrainingLiveStatusList(ids []int) []liveapischema.TrainingLiveStatusList {
|
||||
func buildTrainingLiveStatusList(ids []int, snapshotMap map[int]session.LiveStatusSnapshot) []liveapischema.TrainingLiveStatusList {
|
||||
result := make([]liveapischema.TrainingLiveStatusList, 0, len(ids))
|
||||
for _, id := range ids {
|
||||
snapshot := snapshotMap[id]
|
||||
result = append(result, liveapischema.TrainingLiveStatusList{
|
||||
LiveDifficultyID: id,
|
||||
Status: 1,
|
||||
HiScore: 0,
|
||||
HiComboCount: 0,
|
||||
ClearCnt: 0,
|
||||
AchievedGoalIDList: []int{},
|
||||
Status: snapshot.Status,
|
||||
HiScore: snapshot.HiScore,
|
||||
HiComboCount: snapshot.HiComboCount,
|
||||
ClearCnt: snapshot.ClearCnt,
|
||||
AchievedGoalIDList: snapshot.AchievedGoalIDList,
|
||||
})
|
||||
}
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user