Skip to content

Commit 263f503

Browse files
committed
Add method to reset and requeue pipeline
Signed-off-by: Keshav Priyadarshi <git@keshav.space>
1 parent 9bdeba6 commit 263f503

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

vulnerabilities/models.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
from vulnerabilities.utils import normalize_purl
6666
from vulnerabilities.utils import purl_to_dict
6767
from vulnerablecode import __version__ as VULNERABLECODE_VERSION
68-
from vulnerablecode.settings import VULNERABLECODE_ASYNC
6968

7069
logger = logging.getLogger(__name__)
7170

@@ -2073,9 +2072,8 @@ def stop_run(self):
20732072
self.set_run_stopped()
20742073

20752074
def delete_run(self, delete_self=True):
2076-
if VULNERABLECODE_ASYNC and self.run_id:
2077-
if job := self.job:
2078-
job.delete()
2075+
if job := self.job:
2076+
job.delete()
20792077

20802078
if delete_self:
20812079
self.delete()
@@ -2103,6 +2101,12 @@ def dequeue(self):
21032101

21042102
dequeue_job(self.run_id)
21052103

2104+
def requeue(self):
2105+
"""Reset run and requeue pipeline for execution."""
2106+
if job := self.job:
2107+
self.reset_run()
2108+
return job.requeue()
2109+
21062110

21072111
class PipelineSchedule(models.Model):
21082112
"""The Database representation of a pipeline schedule."""

0 commit comments

Comments
 (0)