← Back to Pull requests

[AAP-88671] XLAB Add gamification settings #410

Closed
unknown closed this pull request without merging on Sep 09, 2026 13:42 UTC
View on GitHub
unknown unknown commented on Aug 24, 2026 08:36 UTC
Author

[AAP-88671] Add gamification settings

Description


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

  • - Collection status viewset permissions were changed from Admin restricted to accessible to all authenticated users - restrictions are now handled within individual endpoints
    - Added aditional gamification-related dynamic settings (collection status endpoint)
    show_gamification: whether to show the gamification tabs or not - can be changed by system auditor or admin
    show_dashboard: whether to show the dashboard tab or not (false if regular user)
  • Why is this change needed?

  • - gamification requires a flag indicating whether it should show the gamification tab or not. For regular AAP users, gamification tabs should be shown while the dashboard tabs should stay hidden.
  • How does this change address the issue?

  • - by adding flags (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.

    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. Django superuser superuser - system auditor or admin

    DJANGO_SUPERUSER_PASSWORD=password \
      .venv/bin/python manage.py createsuperuser \
      --username superuser --email superuser@user.com --noinput
    

    5. Normal user normal
    python manage.py shell -c '
    from django.contrib.auth import get_user_model
    
    User = get_user_model()
    user = User.objects.create_user(username="normal", email="normal@user.com", password="normal")
    '
    

    Steps to Test


    1. List collection status data
    curl -s -u superuser:password \
      "http://localhost:8000/api/v1/dashboard_reports/collection_status/" | jq
    

    3. Change show_gamification to true - should be false in previous step (by default)
    curl -kv -s -u superuser:password \
      -X POST "http://localhost:8000/api/v1/dashboard_reports/collection_status/" \
      -d '{"show_gamification": true}' | jq 
    

    5. Repeat step 1 to verify
    6. Try doing steps 1 to 5 with normal user credentials

    Expected Results


    Curl in steps 1 and 4 should show two new options: show_gamification, show_dashboard. By default (if no changes were made prior to testing this), admin should see "show_gamification": false and "show_dashboard": true while the normal user (non-admin) should see both on false (default).

    In step 3, admin should be able to successfully change show_gamification while user normal should get a response code 403 Forbidden with a JSON message since he doesn't have the correct permissions.

    Diff: 507 lines (+380 / -127) across 6 files Reviewer: kcagran Review duration: 23345m
    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 · 507 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.373
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #410"
    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: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    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: 18.8% · Safe to merge
    18.8%