Skip to content

Commit bfcf9d6

Browse files
committed
feat: update pipeline to use new run_interval
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 970dadd commit bfcf9d6

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎vulnerabilities/pipelines/__init__.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ class VulnerableCodePipeline(PipelineDefinition, BasePipelineRun):
145145
# When set to true pipeline is run only once.
146146
# To rerun onetime pipeline reset is_active field to True via migration.
147147
run_once = False
148-
# Interval between runs in hour.
149-
run_interval = 24
148+
# Interval between runs in minutes.
149+
run_interval = 1440
150150
run_priority = PipelineSchedule.ExecutionPriority.DEFAULT
151151

152152
def on_failure(self):
@@ -180,8 +180,8 @@ class VulnerableCodeBaseImporterPipeline(VulnerableCodePipeline):
180180
# When set to true pipeline is run only once.
181181
# To rerun onetime pipeline reset is_active field to True via migration.
182182
run_once = False
183-
# Interval between runs in hour.
184-
run_interval = 24
183+
# Interval between runs in minutes.
184+
run_interval = 1440
185185
run_priority = PipelineSchedule.ExecutionPriority.DEFAULT
186186

187187
@classmethod
@@ -290,8 +290,8 @@ class VulnerableCodeBaseImporterPipelineV2(VulnerableCodePipeline):
290290
# When set to true pipeline is run only once.
291291
# To rerun onetime pipeline reset is_active field to True via migration.
292292
run_once = False
293-
# Interval between runs in hour.
294-
run_interval = 24
293+
# Interval between runs in minutes.
294+
run_interval = 1440
295295
run_priority = PipelineSchedule.ExecutionPriority.DEFAULT
296296

297297
@classmethod

‎vulnerabilities/schedules.py‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def schedule_execution(pipeline_schedule, execute_now=False):
2929
if not execute_now:
3030
first_execution = pipeline_schedule.next_run_date
3131

32-
interval_in_seconds = pipeline_schedule.run_interval * 60 * 60
32+
interval_in_seconds = pipeline_schedule.run_interval * 60
3333

3434
job = scheduler.schedule(
3535
scheduled_time=first_execution,
@@ -97,7 +97,7 @@ def update_pipeline_schedule():
9797
PipelineSchedule.objects.exclude(pipeline_id__in=pipelines.keys()).delete()
9898
for id, pipeline_class in pipelines.items():
9999
run_once = getattr(pipeline_class, "run_once", False)
100-
run_interval = getattr(pipeline_class, "run_interval", 24)
100+
run_interval = getattr(pipeline_class, "run_interval", 1440)
101101
run_priority = getattr(
102102
pipeline_class, "run_priority", PipelineSchedule.ExecutionPriority.DEFAULT
103103
)
@@ -112,6 +112,7 @@ def update_pipeline_schedule():
112112
)
113113

114114
if not created:
115-
pipeline.run_priority = run_priority
116-
pipeline.run_interval = run_interval
117-
pipeline.save()
115+
if pipeline.run_priority != run_priority or pipeline.run_interval != run_interval:
116+
pipeline.run_priority = run_priority
117+
pipeline.run_interval = run_interval
118+
pipeline.save()

0 commit comments

Comments
 (0)