Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colleg wise rpt #1366

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading