From f590b4cc106db53cab22832b5f4a6089d1d0f420 Mon Sep 17 00:00:00 2001 From: Emile Date: Fri, 11 Oct 2019 14:23:30 +0200 Subject: expose user score --- src/docker.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/docker.go') diff --git a/src/docker.go b/src/docker.go index 236580f..79cf67d 100644 --- a/src/docker.go +++ b/src/docker.go @@ -23,7 +23,7 @@ var ( dockerCLI *client.Client // store the amount of flags each user has found - userFlags map[string]int + userScore map[string]int users []string // list of users ) @@ -34,7 +34,8 @@ type Statistics struct { FoundFlag int64 `json:"foundFlag"` FlagTries uint `json:"flagTries"` } `json:"challenges"` - User string `json:"user"` + User string `json:"user"` + Score int `json:"score"` } func setupContext() { @@ -135,17 +136,12 @@ func listDockerContainers() { users = append(users, statsGoStruct.User) } - if userFlags == nil { - userFlags = make(map[string]int) + if userScore == nil { + userScore = make(map[string]int) } - // count the amount of flags each user has found - userFlags[statsGoStruct.User] = 0 - for _, chall := range statsGoStruct.Challenges { - if chall.FoundFlag > 1 { - userFlags[statsGoStruct.User]++ - } - } + // update the score if the individual user + userScore[statsGoStruct.User] = statsGoStruct.Score } } } -- cgit 1.4.1