Skip to content

Commit

Permalink
Rank OWASP Nest community users using total contributions.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedxgouda committed Mar 4, 2025
1 parent 76b9347 commit 0a0282e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/apps/github/index/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class UserIndex(IndexBase):
"idx_bio",
"idx_company",
"idx_contributions",
"idx_contributions_count",
"idx_created_at",
"idx_email",
"idx_followers_count",
Expand All @@ -40,6 +41,7 @@ class UserIndex(IndexBase):
"attributeForDistinct": "idx_login",
"minProximity": 4,
"customRanking": [
"desc(idx_contributions_count)",
"desc(idx_created_at)",
"desc(idx_followers_count)",
],
Expand Down
8 changes: 8 additions & 0 deletions backend/apps/github/models/mixins/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def idx_contributions(self):
.select_related("repository")[:TOP_REPOSITORY_CONTRIBUTORS_LIMIT]
]

@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)

@property
def idx_issues(self):
"""Return issues for indexing."""
Expand Down

0 comments on commit 0a0282e

Please sign in to comment.