← Back to Pull requests

[AAP-88670] XLAB Bring organization ownership data #411

Closed
unknown closed this pull request without merging on Sep 28, 2026 13:35 UTC
View on GitHub
unknown unknown commented on Aug 24, 2026 13:23 UTC
Author

[AAP-88670] Bring organization ownership data

Description


<!-- Mandatory: Provide a clear, concise description of the changes and their purpose -->
  • What is being changed?

  • - Modified GET users/me to include data about the current user's organizations - a list of organizations he's a member of
    - note that the data is being fetched directly from the Gateway API upon the endpoint call.
  • Why is this change needed?

  • - We need this data for the gamification leaderboard data where we say "Your" organization. We need to be able to tell whether the selected organization is in fact the user's organization or not.
  • How does this change address the issue?

  • - See above

    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 -->

    Follow README.md to set up local environment. Make sure metrics_service is running on host 0.0.0.0 and port 8000.

    1. Run a local instance (or docker compose) for AWX and Metrics Service databases with all recent migrations
    2. Update your environment variables to match your local setup - https://github.com/ansible/metrics-service#quick-start-1
    3. A working local AAP-DEV environment
    4. AAP-DEV connected to a local metrics-service instance
    5. Configured sync AAP-DEV with metrics-service

    Steps to Test


    1. Prepare testing data (using the AAP-DEV UI instance) - users are written as "username -> assigned organizations"
    - four organizations: a, b, c, d
    - three testing "Normal" users created: t1 -> a, b, c, d, t2 -> a, c, t3 -> d
    - one testing "Admin" user: ta (administrator doesn't get assigned a specific organization)
    - one testing "Auditor" user: tau -> b, c
    - Password for all users can be test

    2. Manually run sync (so that your local metrics_service DB gets updated with the new data we set through UI)

    curl -sk -u "admin:<admin_password>" -X POST \
      http://localhost:44927/api/metrics/v1/tasks/ \
      -H "Content-Type: application/json" \
      -d '{"name": "manual-sync", "function_name": "sync_resources_from_gateway", "task_data": {}}'
    
    # or (if the above doesn't work)
    python manage.py shell -c "
    from apps.tasks.simple.resource_sync import sync_resources_from_gateway
    print(sync_resources_from_gateway())
    "
    

    3. Curl: /me/ on each user

    curl -sk -u "t1:test" http://localhost:44927/api/metrics/v1/users/me/ | jq
    

    Expected Results


    Note: This is an output for just user t1, but it should be similar for all other users. Feel free to try out.

    Curl output:

    {
      "id": 3,
      "url": "/api/v1/users/3/",
      "related": {},
      "summary_fields": {},
      "last_login": null,
      "is_superuser": false,
      "username": "t1",
      "first_name": "",
      "last_name": "",
      "email": "",
      "is_staff": false,
      "is_active": true,
      "date_joined": "2026-09-22T10:10:03.126868Z",
      "member_of_organizations": [
        {
          "id": 1,
          "name": "a"
        },
        {
          "id": 2,
          "name": "b"
        },
        {
          "id": 3,
          "name": "c"
        },
        {
          "id": 4,
          "name": "d"
        }
      ]
    }
    

    As you can see, we get added a list of organizations of which the user is a member of (member_of_organizations)

    Diff: 554 lines (+415 / -139) across 6 files Reviewer: kcagran Review duration: 50411m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 554 lines diff across 6 files
    0.48
    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.378
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #411"
    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: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    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: 19% · Safe to merge
    19%