Don't schedule a cycle with 0 second duration (#417)

* Don't schedule a cycle with 0 second duration

* PR feedback

* Getting bin_pyl to pass
This commit is contained in:
jbirddog 2023-08-02 04:30:00 -04:00 committed by GitHub
parent 1bc8ffc47d
commit 7ccb0aec62

View File

@ -129,7 +129,15 @@ class ProcessInstanceService:
for cycle in cycles:
db.session.delete(cycle)
db.session.commit()
if cycle_count != 0:
if duration_in_seconds == 0:
raise ApiError(
error_code="process_model_cycle_has_0_second_duration",
message="Can not schedule a process model cycle with a duration in seconds of 0.",
)
cycle = ProcessModelCycleModel(
process_model_identifier=process_model_identifier,
cycle_count=cycle_count,
@ -137,8 +145,7 @@ class ProcessInstanceService:
current_cycle=0,
)
db.session.add(cycle)
db.session.commit()
db.session.commit()
@classmethod
def schedule_next_process_model_cycle(cls, process_instance_model: ProcessInstanceModel) -> None: