示例#1
0
// GET REQUESTS --------------------------------------------------------------------------------------
func getScoreboard(ctx *web.Context) string {
	scoreBoard := domains.Scoreboard{}
	scoreBoard.Scores = make([]domains.UsersPublicFlagInfo, 0)

	users, err := db.GetPublicUsers()
	if err != nil {
		return constructGetResponse("scoreboard", scoreBoard, err)
	}

	for _, user := range users {

		flags, err := db.GetPublicFlagsForUser(user.PublicId)
		if err != nil {
			return constructGetResponse("scoreboard", scoreBoard, err)
		}
		flagInfo := domains.UsersPublicFlagInfo{}
		flagInfo.PublicUser = user
		flagInfo.PublicFlags = flags
		scoreBoard.Scores = append(scoreBoard.Scores, flagInfo)
	}

	return constructGetResponse("scoreboard", scoreBoard, nil)
}
示例#2
0
func getPublicUsers(ctx *web.Context) string {
	users, err := db.GetPublicUsers()
	return constructGetResponse("users", users, err)
}