Skip to content

Commit

Permalink
Show task details in v2beta jobs API endpoint
Browse files Browse the repository at this point in the history
This adds a `detailed` parameter to the `api/v2beta/jobs` API
endpoint.

When the parameter is sent in the request the endpoint will return all
the task properties returned by the `api/v2beta/task` endpoint.
  • Loading branch information
replaceafill authored Jan 2, 2024
1 parent 1b93796 commit 43d46f3
Show file tree
Hide file tree
Showing 13 changed files with 840 additions and 3,346 deletions.
8 changes: 7 additions & 1 deletion src/dashboard/src/components/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
r"ingest/status/(?P<unit_uuid>" + settings.UUID_REGEX + ")",
views.status,
{"unit_type": "unitSIP"},
name="ingest_status",
),
re_path(
r"ingest/waiting", views.waiting_for_user_input, name="waiting_for_user_input"
Expand All @@ -56,8 +57,13 @@
+ settings.UUID_REGEX
+ ")/delete/",
views.mark_hidden,
name="mark_hidden",
),
re_path(
r"^(?P<unit_type>transfer|ingest)/delete/",
views.mark_completed_hidden,
name="mark_completed_hidden",
),
re_path(r"^(?P<unit_type>transfer|ingest)/delete/", views.mark_completed_hidden),
re_path(
r"^ingest/reingest/approve", views.reingest_approve, name="reingest_approve"
),
Expand Down
14 changes: 6 additions & 8 deletions src/dashboard/src/components/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def get_unit_status(unit_uuid, unit_type):
def status(request, unit_uuid, unit_type):
# Example: http://127.0.0.1/api/transfer/status/?username=mike&api_key=<API key>
response = {}
error = None

# Get info about unit
if unit_type == "unitTransfer":
Expand Down Expand Up @@ -283,12 +282,6 @@ def status(request, unit_uuid, unit_type):
return _error_response(msg, status_code=400)
response.update(status_info)

if error is not None:
response["message"] = error
response["error"] = True
return django.http.HttpResponseServerError( # 500
json.dumps(response), content_type="application/json"
)
response["message"] = f"Fetched status for {unit_uuid} successfully."
return helpers.json_response(response)

Expand Down Expand Up @@ -934,10 +927,15 @@ def unit_jobs(request, unit_uuid):
name = remove_prefix(name, "Job:")
jobs = jobs.filter(jobtype=name.strip())

detailed_output = "detailed" in request.GET

for job in jobs.prefetch_related("task_set"):
job_link_uuid = job.microservicechainlink
link_uuid = str(job_link_uuid) if job_link_uuid is not None else None
tasks = [format_task(task) for task in job.task_set.all()]
tasks = [
format_task(task, detailed_output=detailed_output)
for task in job.task_set.all()
]
result.append(
{
"uuid": str(job.jobuuid),
Expand Down
74 changes: 0 additions & 74 deletions src/dashboard/tests/fixtures/files.json

This file was deleted.

36 changes: 0 additions & 36 deletions src/dashboard/tests/fixtures/jobs-failed.json

This file was deleted.

Loading

0 comments on commit 43d46f3

Please sign in to comment.