mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -06:00
7848 review changes
This commit is contained in:
parent
d3953a2f6d
commit
ff24a3abe4
@ -202,7 +202,7 @@ class TaskDeleteView(APIView):
|
|||||||
return "Background Task"
|
return "Background Task"
|
||||||
|
|
||||||
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
||||||
def get(self, request, task_id, format=None):
|
def post(self, request, task_id, format=None):
|
||||||
delete_rq_job(task_id)
|
delete_rq_job(task_id)
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ class TaskRequeueView(APIView):
|
|||||||
return "Background Task"
|
return "Background Task"
|
||||||
|
|
||||||
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
||||||
def get(self, request, task_id, format=None):
|
def post(self, request, task_id, format=None):
|
||||||
requeue_rq_job(task_id)
|
requeue_rq_job(task_id)
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class TaskEnqueueView(APIView):
|
|||||||
return "Background Task"
|
return "Background Task"
|
||||||
|
|
||||||
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
||||||
def get(self, request, task_id, format=None):
|
def post(self, request, task_id, format=None):
|
||||||
enqueue_rq_job(task_id)
|
enqueue_rq_job(task_id)
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ class TaskStopView(APIView):
|
|||||||
return "Background Task"
|
return "Background Task"
|
||||||
|
|
||||||
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
@extend_schema(responses={200: OpenApiTypes.OBJECT})
|
||||||
def get(self, request, task_id, format=None):
|
def post(self, request, task_id, format=None):
|
||||||
stopped_jobs = stop_rq_job(task_id)
|
stopped_jobs = stop_rq_job(task_id)
|
||||||
if len(stopped_jobs) == 1:
|
if len(stopped_jobs) == 1:
|
||||||
return HttpResponse(status=200)
|
return HttpResponse(status=200)
|
||||||
|
@ -16,6 +16,9 @@ from rq.registry import (
|
|||||||
|
|
||||||
|
|
||||||
def get_rq_jobs_from_status(queue, status):
|
def get_rq_jobs_from_status(queue, status):
|
||||||
|
"""
|
||||||
|
Return the RQ jobs with the given status.
|
||||||
|
"""
|
||||||
jobs = []
|
jobs = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -49,6 +52,9 @@ def get_rq_jobs_from_status(queue, status):
|
|||||||
|
|
||||||
|
|
||||||
def delete_rq_job(job_id):
|
def delete_rq_job(job_id):
|
||||||
|
"""
|
||||||
|
Deletes the specified RQ job.
|
||||||
|
"""
|
||||||
config = QUEUES_LIST[0]
|
config = QUEUES_LIST[0]
|
||||||
try:
|
try:
|
||||||
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
||||||
@ -64,6 +70,9 @@ def delete_rq_job(job_id):
|
|||||||
|
|
||||||
|
|
||||||
def requeue_rq_job(job_id):
|
def requeue_rq_job(job_id):
|
||||||
|
"""
|
||||||
|
Requeues the specified RQ job.
|
||||||
|
"""
|
||||||
config = QUEUES_LIST[0]
|
config = QUEUES_LIST[0]
|
||||||
try:
|
try:
|
||||||
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
||||||
@ -77,6 +86,9 @@ def requeue_rq_job(job_id):
|
|||||||
|
|
||||||
|
|
||||||
def enqueue_rq_job(job_id):
|
def enqueue_rq_job(job_id):
|
||||||
|
"""
|
||||||
|
Enqueues the specified RQ job.
|
||||||
|
"""
|
||||||
config = QUEUES_LIST[0]
|
config = QUEUES_LIST[0]
|
||||||
try:
|
try:
|
||||||
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
||||||
@ -106,6 +118,9 @@ def enqueue_rq_job(job_id):
|
|||||||
|
|
||||||
|
|
||||||
def stop_rq_job(job_id):
|
def stop_rq_job(job_id):
|
||||||
|
"""
|
||||||
|
Stops the specified RQ job.
|
||||||
|
"""
|
||||||
config = QUEUES_LIST[0]
|
config = QUEUES_LIST[0]
|
||||||
try:
|
try:
|
||||||
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
job = RQ_Job.fetch(job_id, connection=get_redis_connection(config['connection_config']),)
|
||||||
|
@ -349,8 +349,7 @@ class BackgroundTaskListView(TableMixin, BaseRQView):
|
|||||||
if status == RQJobStatus.QUEUED:
|
if status == RQJobStatus.QUEUED:
|
||||||
return queue.get_jobs()
|
return queue.get_jobs()
|
||||||
|
|
||||||
jobs = get_rq_jobs_from_status(queue, status)
|
return get_rq_jobs_from_status(queue, status)
|
||||||
return jobs
|
|
||||||
|
|
||||||
def get(self, request, queue_index, status):
|
def get(self, request, queue_index, status):
|
||||||
queue = get_queue_by_index(queue_index)
|
queue = get_queue_by_index(queue_index)
|
||||||
|
Loading…
Reference in New Issue
Block a user