Commit 1792d621 authored by fred's avatar fred
Browse files

performance: use select_related() when computing program

parent 9dafe09f
......@@ -45,14 +45,14 @@ def day_program(date):
date_start = datetime(*date.timetuple()[:3])
date_end = date_start + timedelta(days=1)
diffusions = Diffusion.objects.filter(
diffusions = Diffusion.objects.select_related().filter(
datetime__range=(date_start, date_end)).order_by('datetime')
diffusions = [x for x in diffusions if x.datetime >= date_start and
x.datetime < date_end]
dt = datetime(2007, 1, date.weekday()+1, Schedule.DAY_HOUR_START)
day_schedule = Schedule.objects.filter(datetime__gte=dt).filter(
datetime__lt=dt+timedelta(days=1)).order_by('datetime')
day_schedule = Schedule.objects.select_related().filter(
datetime__gte=dt, datetime__lt=dt+timedelta(days=1)).order_by('datetime')
week_no = (date.day-1) // 7
program = [x for x in day_schedule if x.match_week(week_no)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment