Compare commits

..

2 Commits

Author SHA1 Message Date
maru
7dbcb18ebf
Use INSERT instead of REPLACE for savedata storage functions 2024-05-08 17:23:07 -04:00
maru
0ead2da2da
Remove unused endpoint game/playercount 2024-05-08 15:47:56 -04:00
3 changed files with 2 additions and 7 deletions

View File

@ -40,7 +40,6 @@ func Init(mux *http.ServeMux) {
mux.HandleFunc("GET /account/logout", handleAccountLogout)
// game
mux.HandleFunc("GET /game/playercount", handleGamePlayerCount)
mux.HandleFunc("GET /game/titlestats", handleGameTitleStats)
mux.HandleFunc("GET /game/classicsessioncount", handleGameClassicSessionCount)

View File

@ -144,10 +144,6 @@ func handleAccountLogout(w http.ResponseWriter, r *http.Request) {
// game
func handleGamePlayerCount(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(strconv.Itoa(playerCount)))
}
func handleGameTitleStats(w http.ResponseWriter, r *http.Request) {
err := json.NewEncoder(w).Encode(defs.TitleStats{
PlayerCount: playerCount,

View File

@ -65,7 +65,7 @@ func StoreSystemSaveData(uuid []byte, data defs.SystemSaveData) error {
return err
}
_, err = handle.Exec("REPLACE INTO systemSaveData (uuid, data, timestamp) VALUES (?, ?, UTC_TIMESTAMP())", uuid, buf.Bytes())
_, err = handle.Exec("INSERT INTO systemSaveData (uuid, data, timestamp) VALUES (?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE data = ?, timestamp = UTC_TIMESTAMP()", uuid, buf.Bytes(), buf.Bytes())
if err != nil {
return err
}
@ -116,7 +116,7 @@ func StoreSessionSaveData(uuid []byte, data defs.SessionSaveData, slot int) erro
return err
}
_, err = handle.Exec("REPLACE INTO sessionSaveData (uuid, slot, data, timestamp) VALUES (?, ?, ?, UTC_TIMESTAMP())", uuid, slot, buf.Bytes())
_, err = handle.Exec("INSERT INTO sessionSaveData (uuid, slot, data, timestamp) VALUES (?, ?, ?, UTC_TIMESTAMP()) ON DUPLICATE KEY UPDATE data = ?, timestamp = UTC_TIMESTAMP()", uuid, slot, buf.Bytes(), buf.Bytes())
if err != nil {
return err
}