Skip to content

Commit

Permalink
perf: 删除job-execution/asset-detail接口
Browse files Browse the repository at this point in the history
  • Loading branch information
w940853815 authored and ibuler committed Mar 18, 2024
1 parent 80a506e commit 90d4914
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 53 deletions.
14 changes: 1 addition & 13 deletions apps/ops/api/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from ops.serializers.job import JobSerializer, JobExecutionSerializer, FileSerializer, JobTaskStopSerializer

__all__ = [
'JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView',
'JobAssetDetail', 'JobExecutionTaskDetail', 'UsernameHintsAPI'
'JobViewSet', 'JobExecutionViewSet', 'JobRunVariableHelpAPIView', 'JobExecutionTaskDetail', 'UsernameHintsAPI'
]

from ops.tasks import run_ops_job_execution
Expand Down Expand Up @@ -226,17 +225,6 @@ def stop(self, request, *args, **kwargs):
return Response({'task_id': task_id}, status=200)


class JobAssetDetail(APIView):
rbac_perms = {
'get': ['ops.view_jobexecution'],
}

def get(self, request, **kwargs):
execution_id = request.query_params.get('execution_id', '')
execution = get_object_or_404(JobExecution, id=execution_id, creator=request.user)
return Response(data=execution.assent_result_detail)


class JobExecutionTaskDetail(APIView):
rbac_perms = {
'GET': ['ops.view_jobexecution'],
Expand Down
39 changes: 0 additions & 39 deletions apps/ops/models/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,45 +254,6 @@ def current_job(self):
return self.job.get_history(self.job_version)
return self.job

@property
def assent_result_detail(self):
if not self.is_finished or self.summary.get('error'):
return None
result = {
"summary": self.summary,
"detail": [],
}
for asset in self.current_job.assets.all():
asset_detail = {
"name": asset.name,
"status": "ok",
"tasks": [],
}
if self.summary.get("excludes", None) and self.summary["excludes"].get(asset.name, None):
asset_detail.update({"status": "excludes"})
result["detail"].append(asset_detail)
break
if self.result["dark"].get(asset.name, None):
asset_detail.update({"status": "failed"})
for key, task in self.result["dark"][asset.name].items():
task_detail = {"name": key,
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
asset_detail["tasks"].append(task_detail)
if self.result["failures"].get(asset.name, None):
asset_detail.update({"status": "failed"})
for key, task in self.result["failures"][asset.name].items():
task_detail = {"name": key,
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
asset_detail["tasks"].append(task_detail)

if self.result["ok"].get(asset.name, None):
for key, task in self.result["ok"][asset.name].items():
task_detail = {"name": key,
"output": "{}{}".format(task.get("stdout", ""), task.get("stderr", ""))}
asset_detail["tasks"].append(task_detail)
result["detail"].append(asset_detail)
return result

def compile_shell(self):
if self.current_job.type != 'adhoc':
return
Expand Down
1 change: 0 additions & 1 deletion apps/ops/urls/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
urlpatterns = [
path('playbook/<uuid:pk>/file/', api.PlaybookFileBrowserAPIView.as_view(), name='playbook-file'),
path('variables/help/', api.JobRunVariableHelpAPIView.as_view(), name='variable-help'),
path('job-execution/asset-detail/', api.JobAssetDetail.as_view(), name='asset-detail'),
path('job-execution/task-detail/<uuid:task_id>/', api.JobExecutionTaskDetail.as_view(), name='task-detail'),
path('username-hints/', api.UsernameHintsAPI.as_view(), name='username-hints'),
path('ansible/job-execution/<uuid:pk>/log/', api.AnsibleTaskLogApi.as_view(), name='job-execution-log'),
Expand Down

0 comments on commit 90d4914

Please sign in to comment.