diff --git a/api/common/common_views.py b/api/common/common_views.py index 5e0c8d72..19b52caa 100644 --- a/api/common/common_views.py +++ b/api/common/common_views.py @@ -28,7 +28,7 @@ def get(self, request): learning_circle_count = LearningCircle.objects.all().count() total_no_enrollment = UserCircleLink.objects.filter(accepted=True).count() circle_count_by_ig = LearningCircle.objects.all().values(ig_name=F('ig__name')).annotate( - total_circles=Count('id')) + total_circles=Count('id'), total_users=Count('ig__learningcircle__usercirclelink__user', distinct=True)) unique_user_count = UserCircleLink.objects.filter(accepted=True).values('user').distinct().count() return CustomResponse(response={'lc_count': learning_circle_count, 'total_enrollment': total_no_enrollment, @@ -122,6 +122,16 @@ def get(self, request): return CommonUtils.generate_csv(student_info_data, "Learning Circle Report") +class CollegeWiseLcReport(APIView): + + def get(self, request): + learning_circles_info = LearningCircle.objects.filter(org__org_type=OrganizationType.COLLEGE.value).annotate( + user_count=Count('usercirclelink'), + org_name=F('org__title') + ).values('name', 'user_count', 'org_name') + return CustomResponse(response=learning_circles_info).get_success_response() + + class GlobalCountAPI(APIView): def get(self, request): diff --git a/api/common/urls.py b/api/common/urls.py index 14f20769..0a695775 100644 --- a/api/common/urls.py +++ b/api/common/urls.py @@ -5,6 +5,7 @@ urlpatterns = [ path('lc-dashboard/', common_views.LcDashboardAPI.as_view()), path('lc-report/', common_views.LcReportAPI.as_view()), + path('college-wise-lc-report/', common_views.CollegeWiseLcReport.as_view()), path('download/lc-report/', common_views.LcReportDownloadAPI.as_view()), path('global-count/', common_views.GlobalCountAPI.as_view()), ]