From a653518cfd1f2d5b22517a6943556237b9f322be Mon Sep 17 00:00:00 2001 From: abutalib-kiwi Date: Wed, 13 Sep 2023 14:38:18 +0530 Subject: [PATCH 1/2] fixed article reward points notification for 0 points earned --- junior/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/junior/views.py b/junior/views.py index 28ab9d6..0c6a065 100644 --- a/junior/views.py +++ b/junior/views.py @@ -712,7 +712,7 @@ class CompleteArticleAPIView(views.APIView): total_earn_points=Sum('earn_points'))['total_earn_points'] data = {"total_earn_points":total_earn_points} send_notification.delay(ARTICLE_REWARD_POINTS, None, None, - request.user.id, {'points': total_earn_points}) + request.user.id, {'points': total_earn_points if total_earn_points else 0}) return custom_response(SUCCESS_CODE['3042'], data, response_status=status.HTTP_200_OK) except Exception as e: return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST) From e157e98a177550b28ae1d023f6454a9ded57eeab Mon Sep 17 00:00:00 2001 From: abutalib-kiwi Date: Wed, 13 Sep 2023 14:45:47 +0530 Subject: [PATCH 2/2] fixed article reward points notification for 0 points earned --- junior/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/junior/views.py b/junior/views.py index 0c6a065..3d7ab31 100644 --- a/junior/views.py +++ b/junior/views.py @@ -711,8 +711,9 @@ class CompleteArticleAPIView(views.APIView): is_answer_correct=True).aggregate( total_earn_points=Sum('earn_points'))['total_earn_points'] data = {"total_earn_points":total_earn_points} - send_notification.delay(ARTICLE_REWARD_POINTS, None, None, - request.user.id, {'points': total_earn_points if total_earn_points else 0}) + if total_earn_points: + send_notification.delay(ARTICLE_REWARD_POINTS, None, None, + request.user.id, {'points': total_earn_points}) return custom_response(SUCCESS_CODE['3042'], data, response_status=status.HTTP_200_OK) except Exception as e: return custom_error_response(str(e), response_status=status.HTTP_400_BAD_REQUEST)