← Back to Pull requests

AAP-95125 XLAB Add the organization ownership data to the Leaderboard API #457

Closed
unknown closed this pull request without merging on Oct 01, 2026 14:38 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 11:34 UTC
Author

AAP-95125 Adding the organization ownership data to the Leaderboard API

Description


<!-- Mandatory: Provide a clear, concise description of the changes and their purpose -->
This pull request updates the organization streak and leaderboard logic to scope results to the current user's organization memberships, rather than the globally busiest organization. It ensures that the organization streak, leaderboard highlighting, and related achievements are personalized for each user. The changes also improve robustness when organization membership data is unavailable and enhance test coverage for these scenarios.

Personalized organization streak and leaderboard:

The org_streak and leaderboard are now scoped to the user's busiest organization among their memberships, rather than the busiest overall. If the user has no organizations or none with activity, the streak is empty and zero-filled. [[1]](diffhunk://#diff-4fe1e1feabca7383b24ce87564bb8db4bb23dcc273958fb0b5f8e1bc6170bd4dR258-R298) [[2]](diffhunk://#diff-4fe1e1feabca7383b24ce87564bb8db4bb23dcc273958fb0b5f8e1bc6170bd4dL285-R344) [[3]](diffhunk://#diff-a93df127aa6ddf382c2cefc76870ec8770111cbd27f38d801c6ef9e817e13666L419-R424)
Each leaderboard row now includes a user_organization boolean flag, indicating whether the current user is a member of that organization. [[1]](diffhunk://#diff-4fe1e1feabca7383b24ce87564bb8db4bb23dcc273958fb0b5f8e1bc6170bd4dR258-R298) [[2]](diffhunk://#diff-a93df127aa6ddf382c2cefc76870ec8770111cbd27f38d801c6ef9e817e13666R433-R435)
Organization membership is matched by any name an organization ran under during the window, supporting mid-window renames. [[1]](diffhunk://#diff-4fe1e1feabca7383b24ce87564bb8db4bb23dcc273958fb0b5f8e1bc6170bd4dR258-R298) [[2]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL216-R305)

Error handling and API consistency:

If organization memberships cannot be determined (e.g., due to an error), the user's organization streak is empty, and errors are logged. [[1]](diffhunk://#diff-4fe1e1feabca7383b24ce87564bb8db4bb23dcc273958fb0b5f8e1bc6170bd4dR258-R298) [[2]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL216-R305)
The API schema and serializer are updated so org_streak is always present (never null), but may be empty if the user has no organizations. [[1]](diffhunk://#diff-a93df127aa6ddf382c2cefc76870ec8770111cbd27f38d801c6ef9e817e13666L473-R479) [[2]](diffhunk://#diff-81a9b7058ab72273bd15c4ae5df5a9132a31a86d7c154d88a511b5359709476cL12203-L12208) [[3]](diffhunk://#diff-81a9b7058ab72273bd15c4ae5df5a9132a31a86d7c154d88a511b5359709476cL12642-R12637)

Test improvements:

Extensive new and updated tests verify personalized streaks, leaderboard highlighting, empty states, error handling, and organization renames. [[1]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efR43-R61) [[2]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL216-R305) [[3]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL239-R338) [[4]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL494-R594) [[5]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL576-R677) [[6]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL605-R706) [[7]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efL631-R733) [[8]](diffhunk://#diff-51509534737182423e7b527e2bb782e9e3e1a894be422c1565fab6cb0e1a01efR551-R554)

These changes make the dashboard's organization-related metrics more relevant to each user and ensure correct behavior across edge cases.

Type of Change


<!-- Mandatory: Check one or more boxes that apply -->
  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Documentation update

  • Test update

  • Refactoring (no functional changes)

  • Development environment change

  • Configuration change
  • Self-Review Checklist


    <!-- These items help ensure quality - they complement our automated CI checks -->
  • I have performed a self-review of my code

  • I have added relevant comments to complex code sections

  • I have updated documentation where needed

  • I have considered the security impact of these changes

  • I have considered performance implications

  • I have thought about error handling and edge cases

  • I have tested the changes in my local environment
  • Testing Instructions


    <!-- Optional for test-only changes. Mandatory for all other changes -->
    <!-- Must be detailed enough for reviewers to reproduce -->

    Prerequisites


    <!-- List any specific setup required -->

    Steps to Test


    1.
    2.
    3.

    Expected Results


    <!-- Describe what should happen after following the steps -->

    Additional Context


    <!-- Optional but helpful information -->

    Required Actions


    <!-- Check if changes require work in other areas -->
    <!-- Remove section if no external actions needed -->
  • Requires documentation updates

  • <!-- API docs, feature docs, deployment guides -->
  • Requires downstream repository changes

  • <!-- Specify repos: django-ansible-base, eda-server, etc. -->
  • Requires infrastructure/deployment changes

  • <!-- CI/CD, installer updates, new services -->
  • Requires coordination with other teams

  • <!-- UI team, platform services, infrastructure -->
  • Blocked by PR/MR: #XXX

  • <!-- Reference blocking PRs/MRs with brief context -->

    Screenshots/Logs


    <!-- Add if relevant to demonstrate the changes -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: kcagran Review duration: 183m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #457"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%