mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-02-21 16:11:30 +08:00
fixed metrics call
This commit is contained in:
parent
3048e22787
commit
b57eae4f0c
@ -91,14 +91,14 @@ func Init() error {
|
||||
scheduler.Start()
|
||||
|
||||
if os.Getenv("AWS_ENDPOINT_URL_S3") != "" {
|
||||
go func() {
|
||||
for {
|
||||
err = S3SaveMigration()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
// go func() {
|
||||
// for {
|
||||
// err = S3SaveMigration()
|
||||
// if err != nil {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
// }()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -39,7 +39,7 @@ func Update(uuid []byte, slot int, save any) error {
|
||||
if save.TrainerId == 0 && save.SecretId == 0 {
|
||||
return fmt.Errorf("invalid system data")
|
||||
}
|
||||
|
||||
ProcessSystemMetrics(save, uuid);
|
||||
err = db.UpdateAccountStats(uuid, save.GameStats, save.VoucherCounts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update account stats: %s", err)
|
||||
@ -51,6 +51,7 @@ func Update(uuid []byte, slot int, save any) error {
|
||||
if slot < 0 || slot >= defs.SessionSlotCount {
|
||||
return fmt.Errorf("slot id %d out of range", slot)
|
||||
}
|
||||
ProcessSessionMetrics(save, uuid)
|
||||
return db.StoreSessionSaveData(uuid, save, slot)
|
||||
|
||||
default:
|
||||
@ -65,8 +66,10 @@ func ProcessSystemMetrics(save defs.SystemSaveData, uuid []byte) {
|
||||
func ProcessSessionMetrics(save defs.SessionSaveData, uuid []byte) {
|
||||
err := Cache.Add(fmt.Sprintf("session-%x-%d", uuid, save.GameMode), uuid, time.Minute*5)
|
||||
if err != nil {
|
||||
log.Printf("already cached session")
|
||||
return
|
||||
}
|
||||
log.Printf("increased game mode counter")
|
||||
switch save.GameMode {
|
||||
case 0:
|
||||
gameModeCounter.WithLabelValues("classic").Inc()
|
||||
|
Loading…
x
Reference in New Issue
Block a user