Skip to content

Improved OWASP Nest member ranking algorithm#4273

Open
anurag2787 wants to merge 4 commits intoOWASP:mainfrom
anurag2787:improve-ranking-algorithm
Open

Improved OWASP Nest member ranking algorithm#4273
anurag2787 wants to merge 4 commits intoOWASP:mainfrom
anurag2787:improve-ranking-algorithm

Conversation

@anurag2787
Copy link
Copy Markdown
Contributor

@anurag2787 anurag2787 commented Mar 14, 2026

Proposed change

This PR improves the OWASP Nest member ranking by introducing a calculated_score.

Instead of ranking members only by total contributions, the score also considers factors like recent activity, leadership roles, and involvement across OWASP projects.

Resolves #4200

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 14, 2026

Walkthrough

Adds a persisted per-user calculated_score, computes it during GitHub sync using a multi-factor algorithm, and exposes it in REST schema, GraphQL node, Algolia index, database indexes, and tests.

Changes

Cohort / File(s) Summary
Model & DB migration
backend/apps/github/models/user.py, backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py
Adds calculated_score: FloatField to User with default 0.0 and a descending DB index idx_calc_score_desc.
Index mixin & registry
backend/apps/github/models/mixins/user.py, backend/apps/github/index/registry/user.py
Adds idx_calculated_score property to index mixin and includes it in UserIndex fields and customRanking (desc(idx_calculated_score)).
Scoring implementation
backend/apps/owasp/utils/scoring.py
New scoring module implementing calculate_member_score() and helpers for contributions, leadership, recency, breadth, and consistency with weights and caps.
Sync command
backend/apps/github/management/commands/github_sync_user.py
Integrates score calculation into GitHub sync, adds calculate_member_score(self, user) and persists user.calculated_score with error handling.
API & GraphQL
backend/apps/api/rest/v0/member.py, backend/apps/github/api/internal/nodes/user.py
Adds calculated_score to MemberDetail and UserNode; extends REST list_members ordering to accept calculated_score/-calculated_score and makes -calculated_score the default when unspecified.
Tests
backend/tests/apps/owasp/utils/scoring_test.py, backend/tests/apps/github/management/commands/github_sync_user_test.py, backend/tests/apps/api/rest/v0/member_test.py
Adds comprehensive tests for scoring utilities, sync command score calculation scenarios, and updates API tests to include calculated_score and new default ordering.
Local compose
docker-compose/local/compose.yaml
Renames PostgreSQL volume from db-data to db-data-4200.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

schema

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The docker-compose volume rename (db-data to db-data-4200) is unrelated to the ranking algorithm objective and appears to be an incidental infrastructure change. Remove the docker-compose volume rename or explain its necessity in relation to the ranking algorithm feature; if unrelated, defer to a separate PR.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: introducing a calculated_score to improve member ranking beyond contribution counts.
Linked Issues check ✅ Passed The PR implements all key requirements from issue #4200: calculated_score field added to Member model, scoring algorithm incorporating leadership/recency/breadth/consistency factors, persistence during GitHub sync, and API/search integration.
Docstring Coverage ✅ Passed Docstring coverage is 98.21% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description clearly explains the change: introducing a calculated_score to improve member ranking by considering recent activity, leadership roles, and project involvement beyond just contributions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 13 files

Confidence score: 3/5

  • There is some concrete regression risk in backend/apps/github/management/commands/github_sync_user.py: deduplicating committee memberships by entity_id alone (without entity_type) can undercount memberships for Generic FK records and affect user-facing counts.
  • backend/apps/owasp/utils/scoring.py has a high-confidence logic bug where the 52-week window can span 53 ISO week buckets, allowing consistency scores above the documented 0–100 range; this can produce incorrect displayed/scored results unless capped.
  • The remaining issues are moderate but still relevant: docker-compose/local/compose.yaml volume renaming can reset local developer DB state, and the nullable descending index in backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py may misorder leaderboard rows with NULL scores.
  • Pay close attention to backend/apps/github/management/commands/github_sync_user.py, backend/apps/owasp/utils/scoring.py, docker-compose/local/compose.yaml, and backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py - membership counting correctness, score range enforcement, local data continuity, and NULL sort behavior are the main risks.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docker-compose/local/compose.yaml">

<violation number="1" location="docker-compose/local/compose.yaml:70">
P2: Renaming the local Postgres volume from `db-data` to `db-data-4200` will cause Docker Compose to create a fresh empty database volume on the next startup, stranding existing developer data in the orphaned old volume. Developers will see their local databases and fixtures appear to disappear without explanation. Since this PR is about the member ranking algorithm, this infrastructure change appears unrelated and lacks documentation or migration guidance. Consider reverting to `db-data` or adding documentation explaining the need for this change and how developers can migrate their existing data.</violation>
</file>

<file name="backend/apps/github/management/commands/github_sync_user.py">

<violation number="1" location="backend/apps/github/management/commands/github_sync_user.py:550">
P2: Committee membership counting deduplicates only by entity_id, which can undercount memberships across different entity types. When using Django's Generic Foreign Key (entity_type + entity_id), distinct() on entity_id alone is insufficient as different content types may share the same primary key value. Should use distinct on both entity_type and entity_id (e.g., `.distinct("entity_type", "entity_id")` or restructure query).</violation>
</file>

<file name="backend/tests/apps/owasp/utils/scoring_test.py">

<violation number="1" location="backend/tests/apps/owasp/utils/scoring_test.py:176">
P2: Test name/docstring claims to test "exactly at 90-day boundary" but tests 89 days, leaving off-by-one case unverified</violation>
</file>

<file name="backend/apps/owasp/utils/scoring.py">

<violation number="1" location="backend/apps/owasp/utils/scoring.py:130">
P2: Consistency score can exceed 100: A 52-week lookback window can span 53 ISO week buckets around year boundaries, causing the consistency score to exceed its documented 0-100 range. Add `min(100.0, ...)` to cap the result, following the pattern used by other scoring functions.</violation>
</file>

<file name="backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py">

<violation number="1" location="backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py:16">
P2: Nullable `calculated_score` field with descending index can cause incorrect leaderboard ordering. PostgreSQL sorts NULLs first in descending order unless NULLS LAST is specified. Consider removing `null=True` since there's already a default of 0.0, or ensure ordering queries explicitly handle nulls with `.order_by(F('calculated_score').desc(nulls_last=True))`.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 14, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="backend/tests/apps/owasp/utils/scoring_test.py">

<violation number="1" location="backend/tests/apps/owasp/utils/scoring_test.py:175">
P2: Boundary test no longer exercises the actual 90-day recency cutoff, so an off-by-one bug at exactly 90 days would go undetected. The test name still claims to cover the 'boundary at 90 days' but now tests 89 days instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/tests/apps/api/rest/v0/member_test.py (1)

59-60: ⚠️ Potential issue | 🟡 Minor

Docstring is inconsistent with the test assertion.

The docstring states the default is '-created_at', but the test now correctly asserts '-calculated_score'. Update the docstring to match the new behavior.

📝 Suggested fix
     `@patch`("apps.api.rest.v0.member.UserModel")
     def test_list_members_no_ordering(self, mock_user_model: MagicMock) -> None:
-        """Test listing members without ordering applies default '-created_at'."""
+        """Test listing members without ordering applies default '-calculated_score'."""
         mock_request = MagicMock()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/tests/apps/api/rest/v0/member_test.py` around lines 59 - 60, Update
the docstring in the test_list_members_no_ordering function to match the actual
assertion: replace the current mention of the default ordering '-created_at'
with '-calculated_score' so the test docstring accurately reflects the behavior
being asserted in the test.
🧹 Nitpick comments (3)
backend/tests/apps/api/rest/v0/member_test.py (1)

37-50: Consider adding an assertion for calculated_score.

The test adds calculated_score to member_data but doesn't verify its value in the assertions block. While the schema will validate the field during construction, an explicit assertion would improve test completeness.

✨ Suggested addition
         assert member.twitter_username == member_data["twitter_username"]
         assert member.updated_at == datetime.fromisoformat(updated_at)
         assert member.url == member_data["url"]
+        assert member.calculated_score == member_data["calculated_score"]

         assert not hasattr(member, "email")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/tests/apps/api/rest/v0/member_test.py` around lines 37 - 50, The test
constructs member_data with a calculated_score but never asserts it; add an
assertion in the existing assertions block to verify member.calculated_score
equals member_data["calculated_score"] (or an appropriate typed/rounded
comparison if the value is a float) so the test explicitly validates the
calculated_score field on the Member instance.
backend/apps/owasp/utils/scoring.py (1)

128-131: Redundant rounding in _consistency_score.

The round(..., 2) here is unnecessary since calculate_member_score already rounds the final weighted sum. This double rounding could cause minor precision artifacts.

🔧 Suggested simplification
-    return min(100.0, round(len(active_weeks) / CONSISTENCY_WEEKS * 100.0, 2))
+    return min(100.0, len(active_weeks) / CONSISTENCY_WEEKS * 100.0)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/apps/owasp/utils/scoring.py` around lines 128 - 131, The
_consistency_score function redundantly applies round(..., 2) before
calculate_member_score also rounds the final weighted sum; remove the inner
rounding so _consistency_score returns min(100.0, len(active_weeks) /
CONSISTENCY_WEEKS * 100.0) (still capping with min) to avoid double-rounding
artifacts—update the return expression in _consistency_score that currently
references active_weeks and CONSISTENCY_WEEKS and ensure calculate_member_score
continues to perform the final rounding.
backend/tests/apps/owasp/utils/scoring_test.py (1)

364-391: Test assertion may be fragile depending on weight balance.

The test test_contributions_are_primary_factor asserts score_with_contributions > score_with_leadership, but score_with_leadership includes board member (50 pts) + GSoC mentor (10 pts) + 5 chapter leaders (75 pts) + 5 project leaders (100 pts) + 5 committee members (50 pts) = 285 pts, capped to 80. With weights: leadership contributes 0.25 * 80 = 20, while contributions at 100 count contribute 0.35 * ~66.4 ≈ 23.3 (log2(101) * 10 ≈ 66.4). The assertion holds, but it's testing the weighting rather than "contributions are primary factor." The test name may be misleading.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/tests/apps/owasp/utils/scoring_test.py` around lines 364 - 391, The
test test_contributions_are_primary_factor is misleading because it compares
full scores instead of the specific contribution vs leadership components;
update the test for clarity by either renaming it to reflect that it compares
overall scores (e.g.,
test_contributions_yield_higher_overall_score_in_this_scenario) or change the
assertion to compare the contribution-derived portion to the leadership-derived
portion directly by extracting the contribution and leadership components from
calculate_member_score (or adding a helper that returns both components) so the
test asserts contribution_component > leadership_component while keeping the
same input values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@backend/apps/github/management/commands/github_sync_user.py`:
- Around line 515-521: The except is catching AttributeError but accessing the
reverse OneToOne relation user.owasp_profile raises a RelatedObjectDoesNotExist
(subclass of ObjectDoesNotExist); update the try/except in github_sync_user.py
around the user.owasp_profile access to catch either the specific
RelatedObjectDoesNotExist for that relation or the broader
django.core.exceptions.ObjectDoesNotExist (or import and reference
user.owasp_profile.RelatedObjectDoesNotExist) and then set is_board_member =
False and is_gsoc_mentor = False in that except block so missing reverse
OneToOne relations are handled correctly.
- Around line 550-559: The committee_member_count query is including CANDIDATE
roles; update the EntityMember filter to only count confirmed roles by adding a
role filter (e.g. role__in=[EntityMember.Role.MEMBER, EntityMember.Role.LEADER]
or otherwise exclude EntityMember.Role.CANDIDATE) in the committee_member_count
queryset so it matches the explicit role filtering used for chapter_leader_count
and project_leader_count.
- Around line 561-567: The current aggregation uses
contribution_data.update(...) which overwrites duplicate date keys from
MemberSnapshot.contribution_heatmap_data; change aggregation in the
github_sync_user logic to accumulate counts instead: initialize
contribution_data as a numeric accumulator (e.g., collections.Counter or
defaultdict(int)), iterate each snapshot from
MemberSnapshot.objects.filter(...).values("contribution_heatmap_data"), and for
each date/key in snapshot["contribution_heatmap_data"] add its integer count to
contribution_data[date]; ensure this produces the summed heatmap used by
_recency_score() and _consistency_score().

In `@backend/tests/apps/github/management/commands/github_sync_user_test.py`:
- Around line 986-1025: The test test_calculate_member_score_missing_profile
incorrectly sets mock_user.owasp_profile = None; instead simulate Django's
missing OneToOne reverse relation by making attribute access raise
django.core.exceptions.ObjectDoesNotExist so the production handling is
exercised: in the test (test_calculate_member_score_missing_profile) import
ObjectDoesNotExist and PropertyMock and set type(mock_user).owasp_profile =
PropertyMock(side_effect=ObjectDoesNotExist()) before calling
command.calculate_member_score(mock_user); this change ensures the
calculate_member_score code path that expects an ObjectDoesNotExist is triggered
(and reveals if it wrongly catches AttributeError).

In `@docker-compose/local/compose.yaml`:
- Line 70: The compose volume name was changed to "db-data-4200", which will
orphan existing developer volumes and cause local data loss; revert any
occurrences of "db-data-4200" back to the original "db-data" unless this rename
is intentionally required, or explicitly document in the PR why a destructive
rename is needed; update all instances of the string "db-data-4200" (both the
service volume entries and the volumes list) to "db-data" or add a clear PR note
explaining the forced new volume name.

---

Outside diff comments:
In `@backend/tests/apps/api/rest/v0/member_test.py`:
- Around line 59-60: Update the docstring in the test_list_members_no_ordering
function to match the actual assertion: replace the current mention of the
default ordering '-created_at' with '-calculated_score' so the test docstring
accurately reflects the behavior being asserted in the test.

---

Nitpick comments:
In `@backend/apps/owasp/utils/scoring.py`:
- Around line 128-131: The _consistency_score function redundantly applies
round(..., 2) before calculate_member_score also rounds the final weighted sum;
remove the inner rounding so _consistency_score returns min(100.0,
len(active_weeks) / CONSISTENCY_WEEKS * 100.0) (still capping with min) to avoid
double-rounding artifacts—update the return expression in _consistency_score
that currently references active_weeks and CONSISTENCY_WEEKS and ensure
calculate_member_score continues to perform the final rounding.

In `@backend/tests/apps/api/rest/v0/member_test.py`:
- Around line 37-50: The test constructs member_data with a calculated_score but
never asserts it; add an assertion in the existing assertions block to verify
member.calculated_score equals member_data["calculated_score"] (or an
appropriate typed/rounded comparison if the value is a float) so the test
explicitly validates the calculated_score field on the Member instance.

In `@backend/tests/apps/owasp/utils/scoring_test.py`:
- Around line 364-391: The test test_contributions_are_primary_factor is
misleading because it compares full scores instead of the specific contribution
vs leadership components; update the test for clarity by either renaming it to
reflect that it compares overall scores (e.g.,
test_contributions_yield_higher_overall_score_in_this_scenario) or change the
assertion to compare the contribution-derived portion to the leadership-derived
portion directly by extracting the contribution and leadership components from
calculate_member_score (or adding a helper that returns both components) so the
test asserts contribution_component > leadership_component while keeping the
same input values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c1f2e640-d50b-4caf-8db9-f94378ebcf56

📥 Commits

Reviewing files that changed from the base of the PR and between f1f71ff and b7e12f5.

⛔ Files ignored due to path filters (1)
  • frontend/src/types/__generated__/graphql.ts is excluded by !**/__generated__/**
📒 Files selected for processing (12)
  • backend/apps/api/rest/v0/member.py
  • backend/apps/github/api/internal/nodes/user.py
  • backend/apps/github/index/registry/user.py
  • backend/apps/github/management/commands/github_sync_user.py
  • backend/apps/github/migrations/0045_user_calculated_score_user_idx_calc_score_desc.py
  • backend/apps/github/models/mixins/user.py
  • backend/apps/github/models/user.py
  • backend/apps/owasp/utils/scoring.py
  • backend/tests/apps/api/rest/v0/member_test.py
  • backend/tests/apps/github/management/commands/github_sync_user_test.py
  • backend/tests/apps/owasp/utils/scoring_test.py
  • docker-compose/local/compose.yaml

@sonarqubecloud
Copy link
Copy Markdown

@anurag2787 anurag2787 marked this pull request as ready for review March 14, 2026 20:12
@anurag2787
Copy link
Copy Markdown
Contributor Author

Hi @arkid15r the pr is ready for review

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
backend/apps/github/management/commands/github_sync_user.py (1)

488-498: Consider using a more specific exception type.

The broad except Exception catch at line 496 will catch all exceptions, including programming errors (e.g., TypeError, AttributeError) that might indicate bugs in the scoring logic. This could mask issues during development and testing.

Consider catching more specific exceptions or at minimum logging at ERROR level for unexpected exceptions:

💡 Optional: More targeted exception handling
         # Calculate and update member ranking score
         try:
             score = self.calculate_member_score(user)
             user.calculated_score = score
             user.save(update_fields=["calculated_score"])
             self.stdout.write(self.style.SUCCESS(f"Updated member ranking score: {score:.2f}"))
             logger.info("Updated member ranking score for %s: %.2f", username, score)
-        except Exception as e:
-            self.stderr.write(self.style.WARNING(f"Error calculating member score: {e}"))
-            logger.exception("Error calculating member score for %s", username)
+        except (ObjectDoesNotExist, ValueError) as e:
+            self.stderr.write(self.style.WARNING(f"Error calculating member score: {e}"))
+            logger.warning("Error calculating member score for %s: %s", username, e)
+        except Exception as e:
+            self.stderr.write(self.style.ERROR(f"Unexpected error calculating member score: {e}"))
+            logger.exception("Unexpected error calculating member score for %s", username)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/apps/github/management/commands/github_sync_user.py` around lines 488
- 498, The current broad except Exception around the calculate/update block for
member ranking (the call to calculate_member_score(user), setting
user.calculated_score and user.save) is too wide; narrow it to catch only
expected/validation errors (e.g., ValueError or your domain-specific errors
raised by calculate_member_score) and handle them by logging and continuing, and
add a separate catch-all that logs at ERROR and re-raises unexpected exceptions
so programming errors aren’t swallowed; specifically, replace the single except
Exception block with an except (ValueError, YourDomainScoreError) as e: (write
warning and continue) and an except Exception as e: logger.error("Unexpected
error calculating member score for %s: %s", username, e, exc_info=True); raise
to surface real bugs.
backend/tests/apps/owasp/utils/scoring_test.py (1)

350-362: Decimal place assertion may be fragile for edge cases.

The assertion len(str(score).split(".")[-1]) <= 2 works for most cases but can be unreliable:

  • If score is exactly 0.0, str(0.0) is "0.0" which gives ["0", "0"][-1] = "0" (1 char) ✓
  • If score is 10.0, it gives "0" (1 char) ✓
  • However, if score happens to be an integer-like float (e.g., 10.0), this passes but doesn't truly verify rounding

A more robust approach would check the actual rounding:

💡 Optional: More precise rounding verification
     def test_score_is_rounded_to_two_decimals(self):
         """Test that score is rounded to 2 decimal places."""
         score = calculate_member_score(
             contributions_count=5,
             distinct_repository_count=2,
             chapter_leader_count=0,
             project_leader_count=0,
             committee_member_count=0,
             is_board_member=False,
             is_gsoc_mentor=False,
             contribution_data=None,
         )
-        assert len(str(score).split(".")[-1]) <= 2
+        assert score == round(score, 2)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@backend/tests/apps/owasp/utils/scoring_test.py` around lines 350 - 362, The
test test_score_is_rounded_to_two_decimals should assert that the returned value
from calculate_member_score is equal to its value rounded to two decimals;
replace the fragile string-length check with an assertion like score ==
round(score, 2) so the test reliably verifies the function
calculate_member_score produces a value rounded to two decimal places.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@backend/apps/github/management/commands/github_sync_user.py`:
- Around line 488-498: The current broad except Exception around the
calculate/update block for member ranking (the call to
calculate_member_score(user), setting user.calculated_score and user.save) is
too wide; narrow it to catch only expected/validation errors (e.g., ValueError
or your domain-specific errors raised by calculate_member_score) and handle them
by logging and continuing, and add a separate catch-all that logs at ERROR and
re-raises unexpected exceptions so programming errors aren’t swallowed;
specifically, replace the single except Exception block with an except
(ValueError, YourDomainScoreError) as e: (write warning and continue) and an
except Exception as e: logger.error("Unexpected error calculating member score
for %s: %s", username, e, exc_info=True); raise to surface real bugs.

In `@backend/tests/apps/owasp/utils/scoring_test.py`:
- Around line 350-362: The test test_score_is_rounded_to_two_decimals should
assert that the returned value from calculate_member_score is equal to its value
rounded to two decimals; replace the fragile string-length check with an
assertion like score == round(score, 2) so the test reliably verifies the
function calculate_member_score produces a value rounded to two decimal places.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a3398edc-a794-4584-ba0a-41b70fa5fb25

📥 Commits

Reviewing files that changed from the base of the PR and between b7e12f5 and 14fe5cd.

📒 Files selected for processing (3)
  • backend/apps/github/management/commands/github_sync_user.py
  • backend/tests/apps/github/management/commands/github_sync_user_test.py
  • backend/tests/apps/owasp/utils/scoring_test.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve OWASP Nest member ranking algorithm with calculated scores

1 participant