diff options
Diffstat (limited to 'src/seed.go')
-rw-r--r-- | src/seed.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/seed.go b/src/seed.go index af14d38..dd836ff 100644 --- a/src/seed.go +++ b/src/seed.go @@ -109,3 +109,22 @@ func generateJSONFromChallenges() (string, error) { }) return string(marshalled), marshalError } + +// Generate a JSON string from the stored challenges, just containing enough to call it statistics +func generateJSONFromChallengesForStats() (string, error) { + // To include only required information for statistics, we need to strip the challenge + var strippedChallenges []StatsStrippedChallenge + categories := map[string]int{} + + for _, challenge := range challenges { + // Append challenge to list + strippedChallenges = append(strippedChallenges, stripChallengeForStatistics(challenge)) + + categories[challenge.Category]++ + } + + marshalled, marshalError := json.Marshal(map[string]interface{}{ + "challenges": strippedChallenges, + }) + return string(marshalled), marshalError +} |