Skip to content

Commit

Permalink
[Feature] Two Separate Counters for Endless and Classic Starter Choice (
Browse files Browse the repository at this point in the history
#2)

* Revert "Remove Daily from starter tracking"

This reverts commit ce4aea88de78696c76046c862cdcae2f5d6d871f.

* Added separate starter counter for Endless/Endless Spliced

* Added daily conditional

* Changed starterCounter to also hold information about the game mode.

---------

Co-authored-by: frutescens <info@laptop>
  • Loading branch information
frutescens and frutescens authored Nov 6, 2024
1 parent e6d5561 commit 0da0283
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api/savedata/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ var (
Name: "rogueserver_starter_count",
Help: "The total number of times a specific starter was selected",
},
[]string{"starterKey"},
[]string{"starterKey", "gameMode"},
)
)
32 changes: 19 additions & 13 deletions api/savedata/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,7 @@ func ProcessSessionMetrics(save defs.SessionSaveData, username string) {
return
} else {
log.Printf("increased game mode counter for %s", username)
switch save.GameMode {
case 0:
gameModeCounter.WithLabelValues("classic").Inc()
case 1:
gameModeCounter.WithLabelValues("endless").Inc()
case 2:
gameModeCounter.WithLabelValues("spliced-endless").Inc()
case 3:
gameModeCounter.WithLabelValues("daily").Inc()
case 4:
gameModeCounter.WithLabelValues("challenge").Inc()
}
gameModeCounter.WithLabelValues(getGameModeKey(save.GameMode)).Inc()
}

if save.WaveIndex == 1 && save.GameMode != 3 {
Expand All @@ -108,8 +97,25 @@ func ProcessSessionMetrics(save defs.SessionSaveData, username string) {

key := fmt.Sprintf("%d%s", species, formIndex)
party += key + ","
starterCounter.WithLabelValues(key).Inc()
starterCounter.WithLabelValues(key, getGameModeKey(save.GameMode)).Inc()

}
log.Printf("Incremented starters %s count for %s", party, username)
}
}

func getGameModeKey(gameMode defs.GameMode) string {
switch gameMode {
case 0:
return "classic"
case 1:
return "endless"
case 2:
return "spliced-endless"
case 3:
return "daily"
case 4:
return "challenge"
}
return "none"
}

0 comments on commit 0da0283

Please sign in to comment.