-
-
Notifications
You must be signed in to change notification settings - Fork 629
Add calculated_score field and basic scoring logic #4330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
e9c3f6f
c72c273
ccb63a6
5351332
a4975fe
d9724fc
833c73d
af8e724
25b2694
4b2759c
96b476c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,7 +55,13 @@ class Meta: | |
| ) | ||
|
|
||
| contributions_count = models.PositiveIntegerField( | ||
| verbose_name="Contributions count", default=0 | ||
| verbose_name="Contributions count", | ||
| default=0 | ||
| ) | ||
|
|
||
| calculated_score = models.FloatField( | ||
| default=0, | ||
| help_text="Computed score based on contribution signals" | ||
| ) | ||
|
|
||
| contribution_data = models.JSONField( | ||
|
|
@@ -85,6 +91,12 @@ def issues(self): | |
| """ | ||
| return self.created_issues.all() | ||
|
|
||
| def calculate_score(self): | ||
| score = 0.0 | ||
| # Base contribution score | ||
| score += float( self.contributions_count or 0 ) | ||
| return score | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add docstring and fix formatting. The method is missing a docstring (flagged by static analysis D102) and has non-standard spacing inside the parentheses on Line 97. Also consider adding a return type annotation for clarity. 📝 Suggested fix def calculate_score(self):
+ """Calculate a score based on contribution signals.
+
+ Returns:
+ float: The computed score for this user.
+
+ """
score = 0.0
# Base contribution score
- score += float( self.contributions_count or 0 )
+ score += float(self.contributions_count or 0)
return score🧰 Tools🪛 Ruff (0.15.6)[warning] 94-94: Missing docstring in public method (D102) 🤖 Prompt for AI Agents |
||
|
|
||
| @property | ||
| def nest_url(self) -> str: | ||
| """Get Nest URL for user.""" | ||
|
|
@@ -170,6 +182,7 @@ def from_github(self, gh_user) -> None: | |
| setattr(self, model_field, value) | ||
|
|
||
| self.is_bot = gh_user.type == "Bot" | ||
| self.calculated_score = self.calculate_score() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Score becomes stale when The Since the management command appears to be the primary mechanism for aggregating contribution counts from Consider one of these approaches:
# In github_update_users.py, after setting contributions_count:
user.contributions_count = user_contributions.get(user.id, 0)
user.calculated_score = user.calculate_score()
users.append(user)
# And update bulk_save to include the new field:
User.bulk_save(users, fields=("contributions_count", "calculated_score"))
🤖 Prompt for AI Agents |
||
|
|
||
| def get_absolute_url(self): | ||
| """Get absolute URL for the user.""" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: OWASP/Nest
Length of output: 39202
Create a migration for the
calculated_scorefield.The
calculated_scorefield is defined in the model but lacks a corresponding migration. When the ORM attempts to persist data to this field, the column won't exist in the database, causing failures. Add a migration usingpython manage.py makemigrationsto add this column.🧰 Tools
🪛 Ruff (0.15.6)
[warning] 82-85: Class field
calculated_scoreis defined multiple timesRemove duplicate field definition for
calculated_score(PIE794)
🤖 Prompt for AI Agents