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 committed Dec 4, 2024
1 parent 5eb96f0 commit 3d3a2af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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
7 changes: 6 additions & 1 deletion nexus/logs/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def get_queryset(self):
if text_param:
params["message__text__icontains"] = text_param

return MessageLog.objects.filter(
queryset = MessageLog.objects.filter(
**params
).exclude(
reflection_data__isnull=True
Expand All @@ -162,6 +162,11 @@ def get_queryset(self):
'-created_at'
)

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

return queryset


class LogsViewset(
ReadOnlyModelViewSet
Expand Down

0 comments on commit 3d3a2af

Please sign in to comment.