mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-04-03 03:27:13 +08:00
ServerSide adjustments for Run History function
This commit is contained in:
parent
8577d7978b
commit
e66c44bbba
@ -31,7 +31,6 @@ import (
|
|||||||
"github.com/pagefaultgames/rogueserver/db"
|
"github.com/pagefaultgames/rogueserver/db"
|
||||||
"github.com/pagefaultgames/rogueserver/defs"
|
"github.com/pagefaultgames/rogueserver/defs"
|
||||||
|
|
||||||
"/api/savedata"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -575,8 +574,8 @@ func handleGetRunHistory(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var runHistory any
|
var runHistory defs.RunHistoryData
|
||||||
runHistory, err = savedata.GetRunHistoryData(uuid);
|
runHistory, err = db.GetRunHistoryData(uuid);
|
||||||
|
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
http.Error(w, err.Error(), http.StatusNotFound)
|
||||||
@ -598,14 +597,14 @@ func handleRunHistory(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var data string
|
var data defs.RunHistoryData
|
||||||
err = json.NewDecoder(r.Body).Decode(&data)
|
err = json.NewDecoder(r.Body).Decode(&data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
httpError(w, r, fmt.Errorf("failed to decode request body: %s", err), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = savedata.UpdateRunHistoryData(uuid, data)
|
err = db.UpdateRunHistoryData(uuid, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpError(w, r, err, http.StatusInternalServerError)
|
httpError(w, r, err, http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
|
@ -140,4 +140,4 @@ type SessionHistoryData struct {
|
|||||||
|
|
||||||
type SessionHistoryResult int
|
type SessionHistoryResult int
|
||||||
|
|
||||||
type RunHistoryData map[int]interface{}
|
type RunHistoryData map[string]interface{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user