def api_day_chart(club_id=None, day_id=None): club = get_club(club_id) quantifier = AthleteDistanceByDay(club) scoreboard = quantifier.scoreboard(day_id) return simplejson.dumps([ {'label': q.athlete.name.split()[0], 'value': round(q.value/1000)} for q in scoreboard ])
def api_date_range(club_id, start_date_id, end_date_id): date_start, date_end = day_id_to_date(start_date_id), day_id_to_date(end_date_id) club = get_club(club_id) session['club_id'] = club_id quantifier = AthleteDistanceByDay(club) scoreboard = quantifier.date_range(date_start, date_end) return simplejson.dumps([ {'label': r.athlete.name.split()[0], 'value': round(r.distance/1000)} for r in scoreboard ])
def date_range(club_id, start_date_id, end_date_id): date_start, date_end = day_id_to_date(start_date_id), day_id_to_date(end_date_id) club = get_club(club_id) session['club_id'] = club_id quantifier = AthleteDistanceByDay(club) scoreboard = quantifier.date_range(date_start, date_end) return render_template('rides-by-range.html', club=club, scoreboard=scoreboard, date_start=date_start, date_end=date_end, start_date_id=start_date_id, end_date_id=end_date_id, )
def club_overview(club_id): club = get_club(club_id) quantifier_day = AthleteDistanceByDay(club) last_28_days = quantifier_day.last_28_days()[0:5] quantifier_week = AthleteDistanceByWeek(club) week_scoreboards = dict([(week, quantifier_week.scoreboard(week)) for week in [week_id(monday(0))]]) return render_template('club-overview.html', club=club, last_28_days=last_28_days, week_scoreboards=week_scoreboards, week_id=week_id(monday(0)), week_start = monday(), week_end = monday(+1) )
def daily_scoreboard(club_id, first_day_id=None): days_per_request = 3 base_date = first_day_id and day_id_to_date(first_day_id) or datetime.date.today() days = [(day_id(base_date, -i)) for i in range(0, days_per_request)] club = get_club(club_id) session['club_id'] = club_id quantifier = AthleteDistanceByDay(club) scoreboard = dict((day, quantifier.scoreboard(day)) for day in days) # pprint.pprint([(k, list(v)) for (k,v) in scoreboard.items()]) return render_template('rides-by-day.html', club=club, scoreboard=scoreboard, days=days, next_day_id=day_id(base_date, -days_per_request) )