perf: 优化任务列表支持通过 celery_task_id 查询执行的任务

pull/11623/head
Bai 2023-08-09 19:30:01 +08:00 committed by Bryan
parent ee9687743e
commit 31d2bdd3bb
2 changed files with 3 additions and 2 deletions

View File

@ -24,7 +24,7 @@ __all__ = [
class TaskViewSet(OrgBulkModelViewSet): class TaskViewSet(OrgBulkModelViewSet):
model = Task model = Task
filterset_fields = ("name",) filterset_fields = ("name", "adhoc__execution__celery_task_id")
search_fields = filterset_fields search_fields = filterset_fields
serializer_class = TaskSerializer serializer_class = TaskSerializer
@ -54,6 +54,7 @@ class TaskRun(generics.RetrieveAPIView):
class AdHocViewSet(viewsets.ModelViewSet): class AdHocViewSet(viewsets.ModelViewSet):
queryset = AdHoc.objects.all() queryset = AdHoc.objects.all()
filterset_fields = ('execution__celery_task_id', )
serializer_class = AdHocSerializer serializer_class = AdHocSerializer
def get_serializer_class(self): def get_serializer_class(self):

View File

@ -17,7 +17,7 @@ class AdHocExecutionSerializer(serializers.ModelSerializer):
fields_mini = ['id'] fields_mini = ['id']
fields_small = fields_mini + [ fields_small = fields_mini + [
'hosts_amount', 'timedelta', 'result', 'summary', 'short_id', 'hosts_amount', 'timedelta', 'result', 'summary', 'short_id',
'is_finished', 'is_success', 'is_finished', 'is_success', 'celery_task_id',
'date_start', 'date_finished', 'date_start', 'date_finished',
] ]
fields_fk = ['task', 'task_display', 'adhoc', 'adhoc_short_id',] fields_fk = ['task', 'task_display', 'adhoc', 'adhoc_short_id',]