def start_unstarted_cycles(): """Start missing cycles. This function is used for fixing workflow cycles if that have not been automatically started in the nightly cronjob. It should be manually triggered by a system administrator. """ workflows = _get_unstarted_workflows() for workflow in workflows: tasks_start_days = [task.relative_start_day for tg in workflow.task_groups for task in tg.task_group_tasks] tasks_end_days = [task.relative_end_day for tg in workflow.task_groups for task in tg.task_group_tasks] # We must skip tasks that don't have start days and end days defined if ((not all(tasks_start_days) and not all(tasks_end_days)) or (not tasks_start_days and not tasks_end_days)): logger.info( "Skipping workflow %s (ID: %s) because it doesn't " "have relative start and end days specified", workflow.title, workflow.id, ) continue workflow.next_cycle_start_date = date.today() workflow.non_adjusted_next_cycle_start_date = date.today() db.session.add(workflow) db.session.commit() run_job(start_recurring_cycles) return redirect(url_for('unstarted_cycles'))
def start_unstarted_cycles(): """Start missing cycles. This function is used for fixing workflow cycles if that have not been automatically started in the nightly cronjob. It should be manually triggered by a system administrator. """ workflows = _get_unstarted_workflows() for workflow in workflows: tasks_start_days = [task.relative_start_day for tg in workflow.task_groups for task in tg.task_group_tasks] tasks_end_days = [task.relative_end_day for tg in workflow.task_groups for task in tg.task_group_tasks] # We must skip tasks that don't have start days and end days defined if ((not all(tasks_start_days) and not all(tasks_end_days)) or (not tasks_start_days and not tasks_end_days)): app.logger.info( "Skipping workflow {0} (ID: {1}) because it doesn't " "have relative start and end days specified".format( workflow.title, workflow.id)) continue workflow.next_cycle_start_date = date.today() workflow.non_adjusted_next_cycle_start_date = date.today() db.session.add(workflow) db.session.commit() run_job(start_recurring_cycles) return redirect(url_for('unstarted_cycles'))