Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

The code review leaderboard was querying the wrong model, using incorrect field paths, and had no null safety, causing it to show "No code review data available" despite existing reviews.

Changes

Backend (website/views/user.py)

  • Changed query from GitHubIssue traversal to direct GitHubReview query
  • Added extract_github_username() helper to parse GitHub URLs for avatar display
  • Filtered both leaderboards to tracked repositories only (pull_request__repo__isnull=False)
  • Replaced exclude(field__isnull=True) with filter(field__isnull=False) for performance

Frontend (website/templates/leaderboard_global.html)

  • Fixed field paths: reviews__reviewer__user__*reviewer__user__*
  • Added 3-level avatar fallback: GitHub username → Gravatar → default
  • Added null checks for usernames and GitHub links
  • Standardized styling to #e74c3c and rounded-lg across all panels

Before/After

# Before: Wrong model and field path
reviewed_pr_leaderboard = GitHubReview.objects.values(
    "reviews__reviewer__user__username"  # Wrong field path
)

# After: Correct model and filtering
code_review_leaderboard = GitHubReview.objects.filter(
    reviewer__user__isnull=False,
    pull_request__repo__isnull=False
).values("reviewer__user__username")  # Correct field path
{# Before: No null safety, wrong fields #}
<img src="https://github.com/{{ leader.reviews__reviewer__user__username }}.png">

{# After: Null-safe with proper field extraction #}
{% if leader.github_username %}
    <img src="https://github.com/{{ leader.github_username }}.png">
{% elif leader.reviewer__user__email %}
    <img src="{% gravatar_url leader.reviewer__user__email 50 %}">
{% else %}
    <img src="{% gravatar_url '[email protected]' 50 %}">
{% endif %}

Fixes #4569, #4660

Original prompt

please fix this #4651


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 26, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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

Copilot AI changed the title [WIP] Fix issue described in pull request 4651 Fix code review leaderboard ORM query and field relationships Oct 26, 2025
Copilot AI requested a review from DonnieBLT October 26, 2025 22:03
@DonnieBLT DonnieBLT closed this Nov 16, 2025
@DonnieBLT DonnieBLT deleted the copilot/fix-issue-in-pr-4651 branch November 16, 2025 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Fix and enable tracking of pull request reviews for the TOP BLT PRs leaderboard

2 participants