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: ...@@ -633,7 +633,7 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
solutions = {} solutions = {}
# Cycle each timeslot # Cycle each timeslot
for ts in timeslots: for timeslot in timeslots:
# Contains collisions # Contains collisions
collisions = [] collisions = []
...@@ -641,31 +641,31 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -641,31 +641,31 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
solution_choices = set() solution_choices = set()
# Get collisions for each timeslot # 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 # Add the projected timeslot
projected_entry = { projected_entry = {
"hash": ts.hash, "hash": timeslot.hash,
"start": str(ts.start), "start": str(timeslot.start),
"end": str(ts.end), "end": str(timeslot.end),
} }
for c in collision_list: for existing in colliding_timeslots:
# Add the collision # Add the collision
collision = { collision = {
"timeslot_id": c.id, "timeslot_id": existing.id,
"start": str(c.start), "start": str(existing.start),
"end": str(c.end), "end": str(existing.end),
"playlist_id": c.playlist_id, "playlist_id": existing.playlist_id,
"show_id": c.schedule.show.id, "show_id": existing.schedule.show.id,
"show_name": c.schedule.show.name, "show_name": existing.schedule.show.name,
"schedule_id": c.schedule_id, "schedule_id": existing.schedule_id,
"memo": c.memo, "memo": existing.memo,
} }
# Get note # Get note
try: try:
note = Note.objects.get(timeslot=c.id) note = Note.objects.get(timeslot=existing.id)
collision["note_id"] = note.pk collision["note_id"] = note.pk
except ObjectDoesNotExist: except ObjectDoesNotExist:
collision["note_id"] = None collision["note_id"] = None
...@@ -674,14 +674,12 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -674,14 +674,12 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts:
"""Determine acceptable solutions""" """Determine acceptable solutions"""
if len(collision_list) > 1: if len(colliding_timeslots) > 1:
# If there is more than one collision: Only these two are supported at the # If there is more than one collision: Only these two are supported at the moment
# moment
solution_choices.add("theirs") solution_choices.add("theirs")
solution_choices.add("ours") solution_choices.add("ours")
else: else:
# These two are always possible: Either keep theirs and remove ours or vice # These two are always possible: Either keep theirs and remove ours or vice versa
# versa
solution_choices.add("theirs") solution_choices.add("theirs")
solution_choices.add("ours") solution_choices.add("ours")
...@@ -695,7 +693,7 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -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("theirs-end")
solution_choices.add("ours-end") solution_choices.add("ours-end")
...@@ -709,11 +707,11 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -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("theirs-start")
solution_choices.add("ours-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. # ex. pr.
# +--+ # +--+
...@@ -722,12 +720,12 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -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-end")
solution_choices.add("theirs-start") solution_choices.add("theirs-start")
solution_choices.add("theirs-both") 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. # ex. pr.
# +--+ # +--+
...@@ -736,13 +734,13 @@ def generate_conflicts(timeslots: list[TimeSlot]) -> Conflicts: ...@@ -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-end")
solution_choices.add("ours-start") solution_choices.add("ours-start")
solution_choices.add("ours-both") solution_choices.add("ours-both")
if len(collisions) > 0: if len(collisions) > 0:
solutions[ts.hash] = "" solutions[timeslot.hash] = ""
projected_entry["collisions"] = collisions projected_entry["collisions"] = collisions
projected_entry["solution_choices"] = solution_choices 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