added username

pull/60/head
f-fsantos 3 weeks ago
parent dd818e42c6
commit eefa54fe48

@ -34,6 +34,7 @@ func Update(uuid []byte, slot int, save any) error {
log.Print("failed to update account last activity") log.Print("failed to update account last activity")
} }
username := db.FetchUsernameFromUUID(uuid)
switch save := save.(type) { switch save := save.(type) {
case defs.SystemSaveData: // System case defs.SystemSaveData: // System
if save.TrainerId == 0 && save.SecretId == 0 { if save.TrainerId == 0 && save.SecretId == 0 {
@ -59,17 +60,17 @@ func Update(uuid []byte, slot int, save any) error {
} }
} }
func ProcessSystemMetrics(save defs.SystemSaveData, uuid []byte) { func ProcessSystemMetrics(save defs.SystemSaveData, username string) {
} }
func ProcessSessionMetrics(save defs.SessionSaveData, uuid []byte) { func ProcessSessionMetrics(save defs.SessionSaveData, username string) {
err := Cache.Add(fmt.Sprintf("session-%x-%d", uuid, save.GameMode), uuid, time.Minute*5) err := Cache.Add(fmt.Sprintf("session-%s-%d", username, save.GameMode), uuid, time.Minute*5)
if err != nil { if err != nil {
log.Printf("already cached session") log.Printf("already cached game mode for %s", username)
return return
} } else {
log.Printf("increased game mode counter") log.Printf("increased game mode counter for %s", username)
switch save.GameMode { switch save.GameMode {
case 0: case 0:
gameModeCounter.WithLabelValues("classic").Inc() gameModeCounter.WithLabelValues("classic").Inc()
@ -82,6 +83,8 @@ func ProcessSessionMetrics(save defs.SessionSaveData, uuid []byte) {
case 4: case 4:
gameModeCounter.WithLabelValues("challenge").Inc() gameModeCounter.WithLabelValues("challenge").Inc()
} }
}
if save.WaveIndex == 1 { if save.WaveIndex == 1 {
for i := 0; i < len(save.Party); i++ { for i := 0; i < len(save.Party); i++ {
formIndex = "" formIndex = ""

Loading…
Cancel
Save