From 20414ade587de8684e92540526d69e7ee62a1f72 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Thu, 16 May 2024 16:51:46 -0400
Subject: [PATCH] style: rename varibles for readability

---
 program/services.py | 52 ++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/program/services.py b/program/services.py
index 3431480e..166624bd 100644
--- a/program/services.py
+++ b/program/services.py
@@ -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
-- 
GitLab