Exemple #1
0
func drawFull(w http.ResponseWriter, db *sql.DB, pk int) {
	var context models.HomeContext
	context.Games = database.GetGames(db)
	lastGame := models.LastGame(context.Games)
	context.Users = database.GetUsers(db, pk)
	context.GamesNr = len(context.Games)
	context.UsersNr = len(context.Users)
	context.Guesses = database.GetGuesses(db, pk, context.GamesNr, context.UsersNr, lastGame)
	templates.Render(w, "home", context)
}
Exemple #2
0
func drawSmall(w http.ResponseWriter, db *sql.DB, pk int) {
	var context models.HomeContext
	context.Users = database.GetUsers(db, pk)
	context.UsersNr = len(context.Users)

	allGames := database.GetGames(db)
	lastGame := models.LastGame(allGames)
	s, e := getSlice(len(allGames), lastGame)
	context.Games = allGames[s:e]
	context.Guesses = database.GetSmall(db, pk, context.UsersNr, s, e-s, lastGame)
	templates.Render(w, "small", context)
}