Skip to content
Snippets Groups Projects
Commit 9a1e3817 authored by Andreas Valder's avatar Andreas Valder
Browse files

closes #100

parent 0bc86804
Branches
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@ def timetable():
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 not l['time']:
l['time'] = datetime.fromtimestamp(0)
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']
......@@ -39,7 +41,21 @@ def timetable():
for l in i['lectures']:
# who the hell inserts lectures with zero length?!?!?
l['time_end'] = l['time']+timedelta(minutes=max(l['duration'],1))
for l in sorted([(l['time'],True,l) for l in i['lectures']] + [(l['time_end'],False,l) for l in i['lectures']],key=lambda t:(t[0],t[1])):
# create sweepline input array
sweeplinetupels = [(l['time'],True,l) for l in i['lectures']]
sweeplinetupels += [(l['time_end'],False,l) for l in i['lectures']]
tmp = []
for x in sweeplinetupels:
unique = True
for y in tmp:
if x[0] == y[0] and x[1] == y[1] and x[2]['short'] == y[2]['short']:
unique = False
if unique:
tmp.append(x)
print(x[0],x[1],x[2]['short'])
sweeplinetupels = sorted(tmp, key=lambda t:(t[0],t[1]))
for l in sweeplinetupels:
if l[1]:
curcol += 1
if curcol > maxcol:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment