From 1408f4d41f01fc9cb3ab5f2069a7683bc51cd568 Mon Sep 17 00:00:00 2001 From: SharonAliyas5573 Date: Sun, 14 Jul 2024 11:27:57 +0530 Subject: [PATCH] Refactor UserLogAPI to filter karma activity log based on launchpad_log parameter --- api/launchpad/launchpad_views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/api/launchpad/launchpad_views.py b/api/launchpad/launchpad_views.py index b571ed5e..379bb2d5 100644 --- a/api/launchpad/launchpad_views.py +++ b/api/launchpad/launchpad_views.py @@ -591,11 +591,17 @@ def get(self, request, launchpad_id=None): class UserLogAPI(BaseAPI): def get(self, request, launchpad_id=None): + launchpad_log = request.query_params.get('launchpad_log', False) user, response = self.get_authenticated_user(request, launchpad_id) if response: return response - karma_activity_log = KarmaActivityLog.objects.filter(user=user.id, appraiser_approved=True).order_by("-created_at") - if not karma_activity_log: + + query = Q(user=user.id, appraiser_approved=True) + if launchpad_log: + query &= Q(task__event='launchpad') + karma_activity_log = KarmaActivityLog.objects.filter(query).order_by("-created_at") + if not karma_activity_log.exists(): return CustomResponse(general_message="No karma details available for user").get_success_response() + serializer = UserLogSerializer(karma_activity_log, many=True) return CustomResponse(response=serializer.data).get_success_response() \ No newline at end of file