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 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) )