예제 #1
0
func getSeasonStats(c web.C, w http.ResponseWriter, r *http.Request) *appError {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	season, _ := strconv.Atoi(c.URLParams["year"])

	seasonStats := tournaments.SeasonStats([]int{season})

	encoder := json.NewEncoder(w)
	encoder.Encode(seasonStats)
	return nil
}
예제 #2
0
func getTotalStats(c web.C, w http.ResponseWriter, r *http.Request) *appError {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	tList, err := tournaments.AllTournaments()
	if err != nil {
		return &appError{err, "Cant find tournaments", 404}
	}

	seasons := tList.Seasons()

	fullStats := tournaments.SeasonStats(seasons)

	encoder := json.NewEncoder(w)
	encoder.Encode(fullStats)
	return nil
}