diff --git a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py index 2d342c763084b54567778eeee5ba307d139ab7a3..3cf7383f932d42d00476c4c7275ddc57ce0cad43 100644 --- a/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py +++ b/SAS/TMSS/backend/services/scheduling/lib/dynamic_scheduling.py @@ -287,7 +287,12 @@ class Scheduler: if scheduled_unit: scheduled_units.append(scheduled_unit) - # can we fit any B-prio units in the new gap(s) in the schedule? + # mark the B-prio schedulable units as not placed yet.... + for scheduling_unit in get_dynamically_schedulable_scheduling_units(priority_queue=models.PriorityQueueType.objects.get(value=models.PriorityQueueType.Choices.B.value)).filter(placed=True): + scheduling_unit.placed = False + scheduling_unit.save() + + # ... and see if we can fit any B-prio units in the new gap(s) in the schedule? scheduled_B_units = self.place_B_priority_units_in_gaps_around_scheduling_unit(scheduled_unit, do_schedule=True) scheduled_units.extend(scheduled_B_units) @@ -568,8 +573,9 @@ class Scheduler: # mark the schedulable units that they are not 'placed' yet by the scheduler. for scheduling_unit in get_dynamically_schedulable_scheduling_units(): - scheduling_unit.placed = False - scheduling_unit.save() + if scheduling_unit.placed: + scheduling_unit.placed = False + scheduling_unit.save() # use relatively coarser gridders for mid-term schedule. Just to get a rough idea. self.search_gridder = Gridder(grid_minutes=3*60)