fix dual device and calendar display bug
This commit is contained in:
+21
-8
@@ -293,7 +293,7 @@ class Scheduler:
|
||||
for day, shift_idx in window.shifts
|
||||
]
|
||||
current_shift_pos = 0
|
||||
sequence_in_shift = 0
|
||||
sequence_in_shift = [0] * len(window.shifts)
|
||||
|
||||
for bundle in bundles:
|
||||
bundle_key = (bundle.index, bundle.device)
|
||||
@@ -309,26 +309,39 @@ class Scheduler:
|
||||
|
||||
test_minutes = self._get_test_minutes(test, bundle.device)
|
||||
|
||||
# Advance past any shift that can't fit this test
|
||||
while current_shift_pos < len(window.shifts) and shift_remaining[current_shift_pos] < test_minutes:
|
||||
while current_shift_pos < len(window.shifts) and shift_remaining[current_shift_pos] <= 0:
|
||||
current_shift_pos += 1
|
||||
sequence_in_shift = 0
|
||||
|
||||
if current_shift_pos >= len(window.shifts):
|
||||
break
|
||||
|
||||
shift_day, shift_idx = window.shifts[current_shift_pos]
|
||||
sequence_in_shift += 1
|
||||
shift_remaining[current_shift_pos] -= test_minutes
|
||||
if sum(shift_remaining[current_shift_pos:]) < test_minutes:
|
||||
break
|
||||
|
||||
start_shift_pos = current_shift_pos
|
||||
shift_day, shift_idx = window.shifts[start_shift_pos]
|
||||
sequence_in_shift[start_shift_pos] += 1
|
||||
|
||||
remaining_test_minutes = test_minutes
|
||||
consume_shift_pos = start_shift_pos
|
||||
while remaining_test_minutes > 0 and consume_shift_pos < len(window.shifts):
|
||||
consumed_minutes = min(shift_remaining[consume_shift_pos], remaining_test_minutes)
|
||||
shift_remaining[consume_shift_pos] -= consumed_minutes
|
||||
remaining_test_minutes -= consumed_minutes
|
||||
consume_shift_pos += 1
|
||||
|
||||
window.remaining_minutes -= test_minutes
|
||||
|
||||
while current_shift_pos < len(window.shifts) and shift_remaining[current_shift_pos] <= 0:
|
||||
current_shift_pos += 1
|
||||
|
||||
self.schedule.append(
|
||||
ScheduleEntry(
|
||||
test_id=test,
|
||||
device=bundle.device,
|
||||
scheduled_date=str(shift_day),
|
||||
shift_index=shift_idx,
|
||||
sequence_in_shift=sequence_in_shift,
|
||||
sequence_in_shift=sequence_in_shift[start_shift_pos],
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user