Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/remove result from list endpoint #1577

Merged
merged 12 commits into from
Feb 6, 2025
4 changes: 2 additions & 2 deletions gateway/api/views/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ def list(self, request):

page = self.paginate_queryset(queryset)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paaragon let's use this opportunity to migrate the queryset too. The idea as we commented is to put all the logic related with the ORM in the Repositories. In this case the philosophy would be similar to what we did in the list for functions: https://github.ibm.com/IBM-Q-Software/qiskit-serverless/blob/main/gateway/api/views/programs.py#L104

if page is not None:
serializer = self.get_serializer(page, many=True)
serializer = self.get_serializer_job_without_result(page, many=True)
return self.get_paginated_response(serializer.data)

serializer = self.get_serializer(queryset, many=True)
serializer = self.get_serializer_job_without_result(queryset, many=True)
return Response(serializer.data)

@action(methods=["POST"], detail=True)
Expand Down
17 changes: 2 additions & 15 deletions gateway/tests/api/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ def test_job_list(self):
self.assertEqual(
jobs_response.data.get("results")[0].get("status"), "SUCCEEDED"
)
self.assertEqual(
jobs_response.data.get("results")[0].get("result"), '{"somekey":1}'
)
self.assertEqual(jobs_response.data.get("results")[0].get("result"), None)

def test_job_catalog_list(self):
"""Tests job list authorized."""
Expand All @@ -50,9 +48,7 @@ def test_job_catalog_list(self):
self.assertEqual(jobs_response.status_code, status.HTTP_200_OK)
self.assertEqual(jobs_response.data.get("count"), 1)
self.assertEqual(jobs_response.data.get("results")[0].get("status"), "QUEUED")
self.assertEqual(
jobs_response.data.get("results")[0].get("result"), '{"somekey":1}'
)
self.assertEqual(jobs_response.data.get("results")[0].get("result"), None)

def test_job_serverless_list(self):
"""Tests job list authorized."""
Expand All @@ -63,15 +59,6 @@ def test_job_serverless_list(self):
)
self.assertEqual(jobs_response.status_code, status.HTTP_200_OK)
self.assertEqual(jobs_response.data.get("count"), 2)
job_status = jobs_response.data.get("results")[0].get("status")
if job_status == "SUCCEEDED":
self.assertEqual(
jobs_response.data.get("results")[0].get("result"), '{"somekey":1}'
)
elif job_status == "QUEUED":
self.assertEqual(
jobs_response.data.get("results")[0].get("result"), '{"somekey":2}'
)

def test_job_detail(self):
"""Tests job detail authorized."""
Expand Down