From 4ad62f545bbabd769269ddb13711e255d67a0492 Mon Sep 17 00:00:00 2001 From: ozer550 Date: Thu, 9 Nov 2023 15:10:48 +0530 Subject: [PATCH] Run linting --- .../contentcuration/viewsets/sync/endpoint.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/contentcuration/contentcuration/viewsets/sync/endpoint.py b/contentcuration/contentcuration/viewsets/sync/endpoint.py index 1947d943a1..1832fdb285 100644 --- a/contentcuration/contentcuration/viewsets/sync/endpoint.py +++ b/contentcuration/contentcuration/viewsets/sync/endpoint.py @@ -5,6 +5,9 @@ """ from celery import states from django.db.models import Q +from django_celery_results.models import TaskResult +from django_cte import CTEQuerySet +from django_cte import With from rest_framework.authentication import SessionAuthentication from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response @@ -17,8 +20,7 @@ from contentcuration.tasks import apply_user_changes_task from contentcuration.viewsets.sync.constants import CHANNEL from contentcuration.viewsets.sync.constants import CREATED -from django_celery_results.models import TaskResult -from django_cte import With , CTEQuerySet + class SyncView(APIView): authentication_classes = (SessionAuthentication,) @@ -126,20 +128,20 @@ def return_changes(self, request, channel_revs): def return_tasks(self, request, channel_revs): custom_task_cte = With(CustomTaskMetadata.objects.filter(channel_id__in=channel_revs.keys())) task_result_querySet = CTEQuerySet(model=TaskResult) - query = custom_task_cte.join(task_result_querySet, - task_id=custom_task_cte.col.task_id)\ - .with_cte(custom_task_cte)\ - .filter(status__in=[states.STARTED, states.FAILURE],)\ - .exclude( - task_name__in=[apply_channel_changes_task.name, apply_user_changes_task.name] - ).annotate( - progress = custom_task_cte.col.progress, - channel_id = custom_task_cte.col.channel_id, - ) + query = custom_task_cte.join(task_result_querySet, task_id=custom_task_cte.col.task_id)\ + .with_cte(custom_task_cte)\ + .filter(status__in=[states.STARTED, states.FAILURE],)\ + .exclude( + task_name__in=[apply_channel_changes_task.name, apply_user_changes_task.name] + ).annotate( + progress=custom_task_cte.col.progress, + channel_id=custom_task_cte.col.channel_id, + ) response_payload = { "tasks": query.values("task_id", "task_name", "traceback", "progress", "channel_id", "status"), } + return response_payload def post(self, request):