Update IG count calculation and add karma breakdown to profiles#3073
Conversation
… UserProfileSerializer
…a breakdown calculations
Update IG count calculation and add karma breakdown to profiles
Greptile SummaryThis PR updates campus IG counts and adds detailed karma attribution to user profiles. The main changes are:
|
| Filename | Overview |
|---|---|
| api/dashboard/campus/serializers.py | Changes active IG counting to use campus chapter rows, but duplicate rows can inflate the result. |
| api/dashboard/profile/profile_serializer.py | Adds profile karma breakdowns, with inconsistent classification of tasks created by Intern Leads. |
Reviews (1): Last reviewed commit: "Merge pull request #3072 from DevWithPra..." | Re-trigger Greptile
| return CampusIGChapter.objects.filter( | ||
| org=obj.org, | ||
| is_active=True, | ||
| ).count() |
There was a problem hiding this comment.
Duplicate Chapters Inflate Count
When an organization has multiple active CampusIGChapter rows for the same IG, this returns the number of rows rather than the number of active IGs. The model has no uniqueness constraint for (org, ig), so callers can receive an inflated active_ig_count; the previous implementation explicitly counted distinct IGs.
| return CampusIGChapter.objects.filter( | |
| org=obj.org, | |
| is_active=True, | |
| ).count() | |
| return ( | |
| CampusIGChapter.objects.filter( | |
| org=obj.org, | |
| is_active=True, | |
| ) | |
| .values("ig_id") | |
| .distinct() | |
| .count() | |
| ) |
| When( | ||
| Q(task__hashtag__startswith="#intern-") | Q(is_intern_creator=True), | ||
| then=Value("intern"), | ||
| ), |
There was a problem hiding this comment.
For a general task created by an active Intern Lead, with no event, IG, or #intern- hashtag, this new calculation reports the karma as intern_karma. The existing karma_distribution calculation recognizes only RoleType.INTERN, so the same profile response classifies that karma as general or other and clients cannot reconcile its breakdown fields.
No description provided.