From 21b92f8c74691dd049daf1d56aef8ef5ae18be3c Mon Sep 17 00:00:00 2001 From: abutalib-kiwi Date: Fri, 25 Aug 2023 16:59:10 +0530 Subject: [PATCH] added notification when admin adds a new article --- base/tasks.py | 5 ++--- celerybeat-schedule | Bin 16384 -> 16384 bytes guardian/views.py | 2 +- junior/utils.py | 2 +- notifications/constants.py | 16 ++++++++++++---- notifications/utils.py | 9 +++++++-- web_admin/serializers/article_serializer.py | 6 ++++++ zod_bank/celery.py | 5 +++-- 8 files changed, 32 insertions(+), 13 deletions(-) diff --git a/base/tasks.py b/base/tasks.py index 98d0df0..65dff3b 100644 --- a/base/tasks.py +++ b/base/tasks.py @@ -68,7 +68,7 @@ def notify_top_junior(): task to send notification for top leaderboard junior to all junior's :return: """ - junior_points_qs = JuniorPoints.objects.prefetch_related('junior', 'junior__auth').annotate(rank=Window( + junior_points_qs = JuniorPoints.objects.select_related('junior', 'junior__auth').annotate(rank=Window( expression=Rank(), order_by=[F('total_points').desc(), 'junior__created_at'] )).order_by('-total_points', 'junior__created_at') @@ -76,9 +76,8 @@ def notify_top_junior(): prev_top_position = junior_points_qs.filter(position=1).first() new_top_position = junior_points_qs.filter(rank=1).first() if prev_top_position != new_top_position: - to_user_list = [junior_point.junior.auth for junior_point in junior_points_qs] send_notification_multiple_user(TOP_JUNIOR, new_top_position.junior.auth.id, JUNIOR, - to_user_list, {'points': new_top_position.total_points}) + {'points': new_top_position.total_points}) for junior_point in junior_points_qs: junior_point.position = junior_point.rank junior_point.save() diff --git a/celerybeat-schedule b/celerybeat-schedule index 4ebacd4aa0047e3c5989eee717063f096d44e18e..4c54db222e0832de26f18d1b25337e66a5fdcf70 100644 GIT binary patch delta 226 zcmZo@U~Fh$T%aJt#sC44PM`n+03EJ!O2u^yIDxj zo|j3MY4UF4mdP{CUrBNCFmY7oPstE%n-Vm|n=?a7qleL8N)MBv!Q>BS;*+;ph)?FS xwHD_VV_;12hAEp0QpT*MZ#3D#RC=?Ubv2_j7IT