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: