Files
honoka-chan/internal/handler/api/live/status.go
T
YumeMichi f6466989c6 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>
2026-06-06 16:25:06 +08:00

52 lines
1.3 KiB
Go

package live
import (
liveapischema "honoka-chan/internal/schema/api/live"
"honoka-chan/internal/session"
"time"
"github.com/gin-gonic/gin"
)
func liveStatus(ctx *gin.Context) (res any, err error) {
ss := session.Get(ctx)
normalIDs, err := listAvailableNormalLiveDifficultyIDs(ss)
if err != nil {
return nil, err
}
specialIDs, err := listTodaySpecialRotationDifficultyIDs(ss, time.Now())
if err != nil {
return nil, err
}
trainingIDs, err := listAvailableTrainingLiveDifficultyIDs(ss)
if err != nil {
return nil, err
}
allIDs := make([]int, 0, len(normalIDs)+len(specialIDs)+len(trainingIDs))
allIDs = append(allIDs, normalIDs...)
allIDs = append(allIDs, specialIDs...)
allIDs = append(allIDs, trainingIDs...)
statusSnapshotMap, err := ss.BuildLiveStatusSnapshotMap(allIDs)
if err != nil {
return nil, err
}
res = liveapischema.StatusResp{
Result: liveapischema.StatusData{
NormalLiveStatusList: buildNormalLiveStatusList(normalIDs, statusSnapshotMap),
SpecialLiveStatusList: buildSpecialLiveStatusList(specialIDs, statusSnapshotMap),
TrainingLiveStatusList: buildTrainingLiveStatusList(trainingIDs, statusSnapshotMap),
MarathonLiveStatusList: []any{},
FreeLiveStatusList: []any{},
CanResumeLive: true,
},
Status: 200,
CommandNum: false,
TimeStamp: time.Now().Unix(),
}
return res, err
}