Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 26, 2025

Fixes #4569, #4660. Code Review leaderboard displayed "No code review data available!" due to incorrect ORM query using GitHubIssue instead of GitHubReview. PR leaderboard included untracked repositories and had fragile avatar rendering.

Backend Changes

  • Added extract_github_username() helper - Safely parses GitHub URLs with domain validation to prevent non-GitHub URLs
  • Code Review query: Changed from GitHubIssue.objects.filter(type="pull_request") to GitHubReview.objects with correct field paths (reviewer__user__username vs reviews__reviewer__user__username)
  • PR query: Added filters for repo__isnull=False and user_profile__isnull=True to exclude untracked repos and orphaned PRs
  • Avatar extraction: Both leaderboards now extract GitHub usernames from URLs for proper avatar rendering

Template Changes

  • Field names: Updated from reviews__reviewer__* to reviewer__* to match corrected backend
  • Avatar fallback chain: GitHub avatar (if URL valid) → Gravatar (if email exists) → Default → "Unknown User" text
  • Styling: Unified to #e74c3c brand color, complete rounded borders on all sections
  • Added string_filters templatetag for split filter support

Example

# Before (broken)
GitHubIssue.objects.filter(type="pull_request").values("reviews__reviewer__user__username")
# Returns empty - wrong model, wrong field path

# After (fixed)
GitHubReview.objects.filter(reviewer__user__isnull=False).values("reviewer__user__username")
# Returns actual reviewers
{# Template before #}
{% if leader.reviews__reviewer__user__username %} {# Wrong field #}

{# Template after #}
{% 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 %}
  <span>Unknown User</span>
{% endif %}
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 and others added 2 commits October 26, 2025 22:24
- Added extract_github_username() helper function
- Fixed PR leaderboard to filter tracked repos and extract github_username
- Fixed code review leaderboard to use GitHubReview model with correct field names
- Updated template from reviews__reviewer__* to reviewer__*
- Changed all colors to custom red (#e74c3c)
- Added complete borders (rounded-lg) around all leaderboard sections
- Added proper null safety and "Unknown User" fallbacks
- Created string_filters templatetag for split filter

Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
- Added GitHub domain validation to extract_github_username function
- Now validates URLs start with https://github.com/ or http://github.com/
- Prevents accepting non-GitHub URLs
- Added explanatory comments about loop processing performance

Co-authored-by: DonnieBLT <128622481+DonnieBLT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue in pull request 4651 Fix Code Review and PR leaderboards: correct ORM queries and field mappings Oct 26, 2025
Copilot AI requested a review from DonnieBLT October 26, 2025 22:30
Copilot finished work on behalf of DonnieBLT October 26, 2025 22:30
@DonnieBLT DonnieBLT marked this pull request as ready for review October 27, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

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