Skip to content
Snippets Groups Projects
Verified Commit 20414ade authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

style: rename varibles for readability

parent a041569b
No related branches found
No related tags found
No related merge requests found
......@@ -633,7 +633,7 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
solutions = {}
# Cycle each timeslot
for ts in timeslots:
for timeslot in timeslots:
# Contains collisions
collisions = []
......@@ -641,31 +641,31 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
solution_choices = set()
# Get collisions for each timeslot
collision_list = list(get_colliding_timeslots(ts).order_by("start"))
colliding_timeslots = list(get_colliding_timeslots(timeslot).order_by("start"))
# Add the projected timeslot
projected_entry = {
"hash": ts.hash,
"start": str(ts.start),
"end": str(ts.end),
"hash": timeslot.hash,
"start": str(timeslot.start),
"end": str(timeslot.end),
}
for c in collision_list:
for existing in colliding_timeslots:
# Add the collision
collision = {
"timeslot_id": c.id,
"start": str(c.start),
"end": str(c.end),
"playlist_id": c.playlist_id,
"show_id": c.schedule.show.id,
"show_name": c.schedule.show.name,
"schedule_id": c.schedule_id,
"memo": c.memo,
"timeslot_id": existing.id,
"start": str(existing.start),
"end": str(existing.end),
"playlist_id": existing.playlist_id,
"show_id": existing.schedule.show.id,
"show_name": existing.schedule.show.name,
"schedule_id": existing.schedule_id,
"memo": existing.memo,
}
# Get note
try:
note = Note.objects.get(timeslot=c.id)
note = Note.objects.get(timeslot=existing.id)
collision["note_id"] = note.pk
except ObjectDoesNotExist:
collision["note_id"] = None
......@@ -674,14 +674,12 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
"""Determine acceptable solutions"""
if len(collision_list) > 1:
# If there is more than one collision: Only these two are supported at the
# moment
if len(colliding_timeslots) > 1:
# If there is more than one collision: Only these two are supported at the moment
solution_choices.add("theirs")
solution_choices.add("ours")
else:
# These two are always possible: Either keep theirs and remove ours or vice
# versa
# These two are always possible: Either keep theirs and remove ours or vice versa
solution_choices.add("theirs")
solution_choices.add("ours")
......@@ -695,7 +693,7 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
# | |
# +--+
#
if ts.end > c.start > ts.start <= c.end:
if timeslot.end > existing.start > timeslot.start <= existing.end:
solution_choices.add("theirs-end")
solution_choices.add("ours-end")
......@@ -709,11 +707,11 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
# | |
# +--+
#
if c.start <= ts.start < c.end < ts.end:
if existing.start <= timeslot.start < existing.end < timeslot.end:
solution_choices.add("theirs-start")
solution_choices.add("ours-start")
# Fully overlapping: projected starts earlier and ends later than existing
# Fully overlapping/Superset: projected starts earlier and ends later than existing
#
# ex. pr.
# +--+
......@@ -722,12 +720,12 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
# +--+ | |
# +--+
#
if ts.start < c.start and ts.end > c.end:
if timeslot.start < existing.start and timeslot.end > existing.end:
solution_choices.add("theirs-end")
solution_choices.add("theirs-start")
solution_choices.add("theirs-both")
# Fully overlapping: projected starts later and ends earlier than existing
# Fully overlapping/Subset: projected starts later and ends earlier than existing
#
# ex. pr.
# +--+
......@@ -736,13 +734,13 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
# | | +--+
# +--+
#
if ts.start > c.start and ts.end < c.end:
if timeslot.start > existing.start and timeslot.end < existing.end:
solution_choices.add("ours-end")
solution_choices.add("ours-start")
solution_choices.add("ours-both")
if len(collisions) > 0:
solutions[ts.hash] = ""
solutions[timeslot.hash] = ""
projected_entry["collisions"] = collisions
projected_entry["solution_choices"] = solution_choices
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment