Commit 55ac20c3 authored by fred's avatar fred

fix grid display for the now over complicated Thursday evening

parent 4f97e29a
...@@ -242,7 +242,17 @@ class Grid(TemplateView): ...@@ -242,7 +242,17 @@ class Grid(TemplateView):
continue continue
# here it is, same cell, same emission, several # here it is, same cell, same emission, several
# schedules # schedules
schedule_list.sort(lambda x,y: -cmp(x.get_duration(), y.get_duration())) schedule_list.sort(lambda x,y: cmp(x.get_duration(), y.get_duration()))
schedule = schedule_list[0]
end_time = schedule.datetime + timedelta(
minutes=schedule.get_duration())
grid[i][j].time_label = '%02d:%02d-%02d:%02d' % (
schedule.datetime.hour,
schedule.datetime.minute,
end_time.hour,
end_time.minute)
for schedule in schedule_list[1:]: for schedule in schedule_list[1:]:
grid[i][j].schedules.remove(schedule) grid[i][j].schedules.remove(schedule)
end_time = schedule.datetime + timedelta(minutes=schedule.get_duration()) end_time = schedule.datetime + timedelta(minutes=schedule.get_duration())
...@@ -315,6 +325,7 @@ class Grid(TemplateView): ...@@ -315,6 +325,7 @@ class Grid(TemplateView):
# that is we merge all of them, ignoring the fact # that is we merge all of them, ignoring the fact
# that the other emissions will stop at 8am30 # that the other emissions will stop at 8am30
current_cell_schedules = set(grid[i][j].schedules) current_cell_schedules = set(grid[i][j].schedules)
current_cell_emissions = set([x.emission for x in current_cell_schedules])
cursor = 1 cursor = 1
while True and current_cell_schedules: while True and current_cell_schedules:
same_cell_below = [x for x in grid[i+cursor] if x.y == grid[i][j].y] same_cell_below = [x for x in grid[i+cursor] if x.y == grid[i][j].y]
...@@ -322,13 +333,15 @@ class Grid(TemplateView): ...@@ -322,13 +333,15 @@ class Grid(TemplateView):
cursor += 1 cursor += 1
continue continue
same_cell_below = same_cell_below[0] same_cell_below = same_cell_below[0]
if current_cell_schedules.issubset(same_cell_below.schedules): same_cell_below_emissions = set([x.emission for x in same_cell_below.schedules])
if current_cell_emissions.issubset(same_cell_below_emissions):
# this handles case A (see comment above) # this handles case A (see comment above)
for schedule in current_cell_schedules: for schedule in current_cell_schedules:
if schedule in same_cell_below.schedules: if schedule in same_cell_below.schedules:
same_cell_below.schedules.remove(schedule) same_cell_below.schedules.remove(schedule)
elif same_cell_below.schedules and \ elif same_cell_below_emissions and \
current_cell_schedules.issuperset(same_cell_below.schedules): current_cell_emissions.issuperset(same_cell_below_emissions):
# this handles case B (see comment above) # this handles case B (see comment above)
# we set the cell time label to the longest # we set the cell time label to the longest
# period # period
...@@ -350,6 +363,13 @@ class Grid(TemplateView): ...@@ -350,6 +363,13 @@ class Grid(TemplateView):
end_time.minute) end_time.minute)
grid[i][j].h += 1 grid[i][j].h += 1
grid[i+cursor].remove(same_cell_below) grid[i+cursor].remove(same_cell_below)
elif same_cell_below_emissions and \
current_cell_emissions.intersection(same_cell_below_emissions):
same_cell_below.schedules = [x for x in
same_cell_below.schedules if
x.emission not in
current_cell_emissions or
x.get_duration() < 30]
cursor += 1 cursor += 1
break break
except IndexError: except IndexError:
......
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