File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
backend/apps/github/models Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 2727
2828class User (NodeModel , GenericUserModel , TimestampedModel , UserIndexMixin ):
2929 """User model."""
30+ calculated_score = models .FloatField ( default = 0 )
31+ def calculate_score (self ):
32+ return (
33+ self ._contribution_score ()
34+ + self ._consistency_score ()
35+ + self ._recency_score ()
36+ )
37+ def _contribution_score (self ):
38+ return (self .contributions_count or 0 ) * 1.0
39+ def _consistency_score (self ):
40+ base = self .contributions_count or 0
41+ if base > 50 :
42+ return 25
43+ elif base > 10 :
44+ return 10
45+ return 0
46+ def _recency_score (self ):
47+ return 5 if (self .contributions_count or 0 ) > 0 else 0
3048
3149 class Meta :
3250 """Model options."""
@@ -184,6 +202,7 @@ def from_github(self, gh_user) -> None:
184202 self .is_bot = gh_user .type == "Bot"
185203 self .calculated_score = self .calculate_score ()
186204
205+
187206 def get_absolute_url (self ):
188207 """Get absolute URL for the user."""
189208 return f"/members/{ self .nest_key } "
You can’t perform that action at this time.
0 commit comments