Skip to content

Commit

Permalink
Merge pull request #1432 from gtech-mulearn/dev
Browse files Browse the repository at this point in the history
total_karma_gainers
  • Loading branch information
adnankattekaden authored Oct 27, 2023
2 parents 00e3ea7 + ae3264c commit 5a0eff0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion api/dashboard/task/dash_task_serializer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers

from db.task import TaskList
from db.task import TaskList, KarmaActivityLog


class TaskListSerializer(serializers.ModelSerializer):
Expand All @@ -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")

Expand All @@ -20,6 +22,7 @@ class Meta:
"title",
"description",
"karma",
"total_karma_gainers",
"channel",
"type",
"active",
Expand All @@ -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:
Expand Down

0 comments on commit 5a0eff0

Please sign in to comment.