From 83d411d43ec3c66ca7f70f88d8ad4f2ebe0b7f1f Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Mon, 12 Sep 2016 04:41:42 +0200 Subject: [PATCH] optimization on timetable --- timetable.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/timetable.py b/timetable.py index 42faf95..60ae61e 100644 --- a/timetable.py +++ b/timetable.py @@ -23,8 +23,10 @@ def timetable(): SELECT lectures.*,courses.short FROM lectures JOIN courses ON (lectures.course_id = courses.id) - ORDER BY time ASC'''): + WHERE time < ? and time > ? + ORDER BY time ASC''', i['date']+timedelta(weeks=2), i['date']-timedelta(weeks=2)): # we can not use the where clause of sql to match against the time, because sqlite and mysql use a different syntax -.- + # we still use it to only get the lectures for a 3 week periode if ((l['time'] < e) and (l['time'] > s)) or ((l['time'] + timedelta(minutes=l['duration']) < e) and (l['time'] + timedelta(minutes=l['duration'])> s)): i['lectures'].append(l) oldtime = l['time'] -- GitLab