From 47bb0f39f8857dad45588aac319f768b06855e03 Mon Sep 17 00:00:00 2001 From: anirudh-mk Date: Fri, 27 Oct 2023 20:56:56 +0530 Subject: [PATCH] feat:(TaskListAPI):add field total_karma_gainers --- api/dashboard/task/dash_task_serializer.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/api/dashboard/task/dash_task_serializer.py b/api/dashboard/task/dash_task_serializer.py index 530d3d25..a64fc2d5 100644 --- a/api/dashboard/task/dash_task_serializer.py +++ b/api/dashboard/task/dash_task_serializer.py @@ -1,6 +1,6 @@ from rest_framework import serializers -from db.task import TaskList +from db.task import TaskList, KarmaActivityLog class TaskListSerializer(serializers.ModelSerializer): @@ -9,6 +9,8 @@ class TaskListSerializer(serializers.ModelSerializer): level = serializers.CharField(source="level.name", required=False, default=None) ig = serializers.CharField(source="ig.name", required=False, default=None) org = serializers.CharField(source="org.title", required=False, default=None) + total_karma_gainers = serializers.SerializerMethodField() + created_by = serializers.CharField(source="created_by.fullname") updated_by = serializers.CharField(source="updated_by.fullname") @@ -20,6 +22,7 @@ class Meta: "title", "description", "karma", + "total_karma_gainers", "channel", "type", "active", @@ -35,6 +38,12 @@ class Meta: "created_at", ] + def get_total_karma_gainers(self, obj): + + return obj.karma_activity_log_task.filter( + appraiser_approved=True + ).count() + class TaskModifySerializer(serializers.ModelSerializer): class Meta: