Skip to content

Commit

Permalink
Fix 404 on message_history
Browse files Browse the repository at this point in the history
  • Loading branch information
zMardone authored and AlisoSouza committed Dec 12, 2024
1 parent f6bfc58 commit 8a72f66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nexus/logs/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ def test_null_reflection_data(self):
self.assertEqual(response.status_code, 200)
self.assertEquals(len(content.get("results")), 0)

def test_empty_logs_data(self):
MessageLog.objects.all().delete()

request = self.factory.get(f"/api/{self.project.uuid}/message_history/?page_size=100&started_day={self.started_day}&ended_day={self.ended_day}")
force_authenticate(request, user=self.user)
response = MessageHistoryViewset.as_view({'get': 'list'})(
request,
project_uuid=str(self.project.uuid),
)
response.render()
content = json.loads(response.content)

self.assertEqual(response.status_code, 200)
self.assertEqual(len(content.get("results")), 0)


class TagPercentageViewSetTestCase(APITestCase):

Expand Down
3 changes: 3 additions & 0 deletions nexus/logs/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def get_queryset(self):
}
logs = [log for log in logs if log.message.response_status == status.get(tag_param) and log.reflection_data.get("tag") != "action_started"]

if not logs.exists():
return MessageLog.objects.none()

return logs


Expand Down

0 comments on commit 8a72f66

Please sign in to comment.