Skip to content

Performance improvement and temporary patch removal#3076

Merged
DevWithPranav merged 3 commits into
gtech-mulearn:devfrom
ABHISHEK2k6:dev
Jul 24, 2026
Merged

Performance improvement and temporary patch removal#3076
DevWithPranav merged 3 commits into
gtech-mulearn:devfrom
ABHISHEK2k6:dev

Conversation

@ABHISHEK2k6

Copy link
Copy Markdown
Contributor

No description provided.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR applies two focused improvements: it eliminates an N+1 query on the learning circle detail endpoint by moving total_members from a per-object UserCircleLink.objects.filter(...).count() call to an annotation on the queryset, and it removes several blocks of commented-out "temporary patch" code that had accumulated across the serializer and views.

  • Learning circle detail query (learningcircle_views.py, learningcircle_serializer.py): the detail path now chains select_related("ig", "org", "created_by").annotate(total_members=Count(...)), matching the list path and addressing the previous review's select_related comment. total_members is declared as IntegerField(read_only=True) in the serializer and no longer issues its own query.
  • Timezone consistency (learningcircle_serializer.py): datetime.now() replaced with DateTimeUtils.get_current_utc_time() when creating the creator's meeting attendance record — ensures UTC consistency across the codebase.
  • Mentor profile response shape (mentor_views.py): response_data['linkedin'] is now always written (set to None when a new URL is pending verification), keeping the response contract stable. MentorChangeCompanyAPI simplifies its profile-source query to the most-recently-updated approved record, removing the two-pass tier-priority Case/When logic.

Confidence Score: 5/5

Safe to merge — changes are focused and correct, addressing prior review feedback without introducing regressions.

All three files make targeted, well-scoped changes: the N+1 fix on the detail endpoint is correctly implemented with both select_related and annotate in the view, the serializer field matches, the UTC time fix is straightforward, the mentor response-shape fix keeps the API contract stable, and the removal of dead commented-out code is clean with no orphaned variable references.

No files require special attention.

Important Files Changed

Filename Overview
api/dashboard/learningcircle/learningcircle_serializer.py Replaced per-object count query with annotation-backed IntegerField for total_members; fixed datetime.now() → DateTimeUtils.get_current_utc_time(); removed dead commented-out code. Clean changes.
api/dashboard/learningcircle/learningcircle_views.py Detail fetch now correctly uses select_related + annotate(total_members=...), matching the list path. Removed lat/lon variable bindings and commented-out temporary filters. No new issues introduced.
api/dashboard/mentor/mentor_views.py LinkedIn key now always written to response_data (None when pending verification). MentorChangeCompanyAPI simplified to single approved-profile query ordered by -updated_at. Both changes are intentional and correct.

Reviews (2): Last reviewed commit: "Fixed the greptile review" | Re-trigger Greptile

Comment thread api/dashboard/learningcircle/learningcircle_views.py Outdated
Comment thread api/dashboard/mentor/mentor_views.py Outdated
@DevWithPranav
DevWithPranav merged commit d99be3c into gtech-mulearn:dev Jul 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants