Skip to content

Commit

Permalink
Reimplement the method using Django ORM only.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedxgouda committed Mar 4, 2025
1 parent 0a0282e commit 8aa583b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions backend/apps/github/models/mixins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from apps.github.models.organization import Organization
from apps.github.models.repository_contributor import RepositoryContributor
from django.db.models import Sum

ISSUES_LIMIT = 6
RELEASES_LIMIT = 6
Expand Down Expand Up @@ -110,10 +111,8 @@ def idx_contributions(self):
@property
def idx_contributions_count(self):
"""Return contributions count for indexing."""
contributions_counts = [
rc.contributions_count for rc in RepositoryContributor.objects.filter(user=self)
]
return sum(contributions_counts)
counts = RepositoryContributor.objects.filter(user=self).aggregate(total_contributions=Sum('contributions_count'))['total_contributions']
return counts if counts else 0

@property
def idx_issues(self):
Expand Down

0 comments on commit 8aa583b

Please sign in to comment.