Add run configs. Add redis for cache. Add cache-get in player-list.

This commit is contained in:
MaxJa4
2024-01-20 17:47:39 +01:00
parent 9e3e2723d3
commit 069d76520e
10 changed files with 124 additions and 9 deletions

View File

@@ -34,7 +34,9 @@ func GetAllPlayers(c *gin.Context) {
func GetPlayersByClanHTML(c *gin.Context) {
var players []models.Player
clanId := c.Request.URL.Query().Get("clan_id")
if err := models.DB.Where("clan_id = ?", utils.StringToUint(clanId)).Find(&players).Error; err != nil {
if err := models.DB.
Where("clan_id = ?", utils.StringToUint(clanId)).
Find(&players).Error; err != nil {
return
}
@@ -46,7 +48,13 @@ func GetPlayersByClanHTML(c *gin.Context) {
var htmlOptions string
for _, player := range players {
htmlOptions += fmt.Sprintf(playerItem, player.Name, "----", player.ID, player.ID)
var score string
if val, err := GetCacheByPlayerIDGorm(player.ID, 0); err != nil {
score = "----"
} else {
score = utils.FloatToString(val)
}
htmlOptions += fmt.Sprintf(playerItem, player.Name, score, player.ID, player.ID)
}
c.Header("Content-Type", "text/html")