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

Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 2, 2025

The top earners calculation now prioritizes GitHub issue payments (p2p_amount_usd) for users with linked paid issues, falling back to the existing winnings field otherwise.

Changes

Query Logic (website/views/core.py)

  • Annotate UserProfile with aggregated github_earnings from GitHubIssue.p2p_amount_usd
  • Use Case/When to select GitHub payments when present, otherwise winnings
  • Filter by total_earnings > 0 to exclude zero-balance users

Template (website/templates/home.html)

  • Display total_earnings annotation instead of winnings field

Tests (website/tests/test_core.py)

  • Verify GitHub payments are summed correctly across multiple issues
  • Verify fallback to winnings when no paid GitHub issues exist
  • Verify mixed scenarios (paid issues vs winnings-only users)

Example

top_earners = (
    UserProfile.objects.annotate(
        github_earnings=Coalesce(
            Sum("github_issues__p2p_amount_usd", 
                filter=Q(github_issues__p2p_amount_usd__isnull=False)),
            Value(0),
            output_field=DecimalField(),
        ),
        has_github_issues=Count("github_issues", 
            filter=Q(github_issues__p2p_amount_usd__isnull=False)),
        total_earnings=Case(
            When(has_github_issues__gt=0, then=F("github_earnings")),
            default=Coalesce(F("winnings"), Value(0)),
        ),
    )
    .filter(total_earnings__gt=0)
    .order_by("-total_earnings")[:5]
)

Users with paid GitHub issues display aggregated payment amounts. Users without paid issues continue displaying their winnings field value unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: /home/REDACTED/.cache/pypoetry/virtualenvs/blt-yuw0N2NF-py3.12/bin/python manage.py test website.tests --settings=blt.settings (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

update the top earners calculations to come from the github issues that were paid to them if they have linked github issues otherwise have it come how its setup now


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 2, 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] Update top earners calculations from GitHub issues Calculate top earners from GitHub issue payments with fallback to winnings field Nov 2, 2025
Copilot AI requested a review from DonnieBLT November 2, 2025 16:35
@DonnieBLT DonnieBLT marked this pull request as ready for review November 2, 2025 16:44
@DonnieBLT DonnieBLT merged commit e2f4d3c into main Nov 2, 2025
16 of 32 checks passed
@DonnieBLT DonnieBLT deleted the copilot/update-top-earners-calculations branch November 2, 2025 16:44
@github-project-automation github-project-automation bot moved this from Backlog to Done in 📌 OWASP BLT Project Board Nov 2, 2025
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.

2 participants