Skip to content

Commit

Permalink
Merge pull request #1366 from gtech-mulearn/dev-server
Browse files Browse the repository at this point in the history
colleg wise rpt
  • Loading branch information
adnankattekaden authored Oct 18, 2023
2 parents 83e0cf3 + ea8ce8c commit f8b7d24
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions api/common/common_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from collections import defaultdict

from django.db.models import Sum, F, Case, When, Value, CharField, Count, Q
from django.db.models.functions import Coalesce
from rest_framework.views import APIView
Expand Down Expand Up @@ -130,23 +128,11 @@ class CollegeWiseLcReport(APIView):

def get(self, request):
learning_circles_info = LearningCircle.objects.filter(org__org_type=OrganizationType.COLLEGE.value) \
.values('org__title', 'name') \
.annotate(user_count=Count('usercirclelink')) \
.order_by('org__title')

org_learning_circles = defaultdict(list)

for info in learning_circles_info:
org_name = info['org__title']
org_learning_circles[org_name].append({
'name': info['name'],
'user_count': info['user_count']
})

result_list = [{"org_name": org_name, "learning_circles": circles} for org_name, circles in
org_learning_circles.items()]
.values(org_title=F('org__title')) \
.annotate(learning_circle_count=Count('id'), user_count=Count('usercirclelink')) \
.order_by('org_title')

return CustomResponse(response=result_list).get_success_response()
return CustomResponse(response=learning_circles_info).get_success_response()


class GlobalCountAPI(APIView):
Expand Down

0 comments on commit f8b7d24

Please sign in to comment.