// WeeklyCountStatsHandler shows a weekly stats by user
WeeklyCountStatsHandler shows a weekly stats by user
// WeeklyCountStatsHandler shows a weekly stats by user
func WeeklyCountStatsHandler(c buffalo.Context) error {
	tx, ok := c.Value("tx").(*pop.Connection)
	if !ok {
		return fmt.Errorf("no transaction found")
	}
	weeklyStats, err := getWeeklyCountStats(tx)
	if err != nil {
		c.Flash().Add("error", fmt.Sprintf("Error fetching weekly stats: %v", err))
	}
	return responder.Wants("html", func(c buffalo.Context) error {
		c.Set("weeklyStats", weeklyStats)
		return c.Render(http.StatusOK, r.HTML("/dashboard/weekly-stats.plush.html"))
	}).Wants("json", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.JSON(weeklyStats))
	}).Wants("xml", func(c buffalo.Context) error {
		return c.Render(http.StatusOK, r.XML(weeklyStats))
	}).Respond(c)
}
func WeeklyCountStatsHandler ( c buffalo . Context ) error { tx , ok := c . Value ( " " ) . ( * pop . Connection ) if ! ok { return fmt . Errorf ( " " ) } weeklyStats , err := getWeeklyCountStats ( tx ) if err != nil { c . Flash ( ) . Add ( " " , fmt . Sprintf ( " " , err ) ) } return responder . Wants ( " " , func ( c buffalo . Context ) error { c . Set ( " " , weeklyStats ) return c . Render ( http . StatusOK , r . HTML ( " " ) ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . JSON ( weeklyStats ) ) } ) . Wants ( " " , func ( c buffalo . Context ) error { return c . Render ( http . StatusOK , r . XML ( weeklyStats ) ) } ) . Respond ( c ) }
WeeklyCountStatsHandler shows a weekly stats by user
WeeklyCountStatsHandler shows a weekly stats by user
// Get the DB connection from the context