← Back to Pull requests

[AAP-92559] XLAB Add on-demand dashboard sync option #523

Closed
unknown closed this pull request without merging on Nov 17, 2026 08:10 UTC
View on GitHub
unknown unknown commented on Nov 04, 2026 14:52 UTC
Author

[AAP-92559] Add on-demand dashboard sync option

Description


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

  • - added option to be able to manually sync the dashboard at any time (on-demand). It reuses houlry sync record builders, which are now shared helpers.
  • Why is this change needed?

  • - Lets developers and operators trigger a dashboard sync manually (backend/API only for now), which can help debugging (and developing).
  • How does this change address the issue?

  • - by adding a task that can be manually run at any time to trigger dashboard sync

    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


    Prerequisites


    Follow README.md to set up a local environment. Make sure metrics_service is running on localhost:8000.

    1. Run local AWX and Metrics Service databases with all recent migrations.
    2. Create the Django superuser admin (admin or system auditor):

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

    3. Make 4 of the seeded AWX jobs eligible. Jobs 3 and 6 are  workflow  and must stay excluded. The seeded jobs are all  pending , which the dashboard collector skips:
    psql "postgresql://myuser:mypassword@localhost:5433/awx" \
      -c "UPDATE main_unifiedjob SET status='successful' WHERE id IN (1,4); UPDATE main_unifiedjob SET status='failed' WHERE id IN (2,5);"
    

    Steps to Test


    1. Baseline: both dashboard tables are empty:
    psql "postgresql://metrics_service:metrics_service@localhost:5432/metrics_service" \
      -c "SELECT count(*) FROM dashboard_job_data" \
      -c "SELECT count(*) FROM dashboard_job_data_host_summary"
    

    2. Trigger the on-demand sync for an explicit range. Note the returned task_id:
    curl -s -u admin:admin -X POST http://localhost:8000/api/v1/tasks/schedule_immediate/ \
      -H "Content-Type: application/json" \
      -d '{"name":"manual dashboard sync","function_name":"sync_dashboard_on_demand","task_data":{"since":"2025-06-13T00:00:00+00:00","until":"2025-06-15T00:00:00+00:00"}}' | jq
    

    3. The scheduler picks it up within about 60 seconds. Poll until status is completed :
    curl -s -u admin:admin http://localhost:8000/api/v1/tasks/<TASK_ID>/ | jq '{status, result_data, error_message}'
    

    4. Verify the synced data:
    psql "postgresql://metrics_service:metrics_service@localhost:5432/metrics_service" \
      -c "SELECT job_id, status, finished FROM dashboard_job_data ORDER BY job_id" \
      -c "SELECT count(*) FROM dashboard_job_data_host_summary"
    

    5. Idempotency: repeat steps 2 to 4 with the same request (new task_id).
    6. Failure handling: an invalid range reports an error and writes nothing. Repeat step 2 with "since":"2025-06-15T00:00:00+00:00","until":"2025-06-13T00:00:00+00:00", wait about a minute, and run the step 3 poll. The task is retried automatically (up to 3 attempts, with a delay).
    7. Do step 2 as unauthenticated user (add -kv to the curl command to get more details)

    Expected Results


  • Step 1: both counts are 0.

  • Step 3: status: completed, result_data has status: success, job_count: 4, host_summary_job_count: 4 and  date_range matching the request.

  • Step 4: 4 rows (jobs 1, 2, 4, 5; the workflow jobs 3 and 6 are excluded) and 8 host summary rows.

  • Step 5: task completed again with job_count: 4; the table counts are unchanged (4 and 8, no duplicates).

  • Step 6:  result_data.error is Invalid date range: ..., and the DB counts stay 4 and 8.

  • Step 7: HTTP/1.1 403 Forbidden
  • Diff: 575 lines (+431 / -144) across 7 files Reviewer: kcagran Review duration: 18318m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 575 lines diff across 7 files
    0.50
    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.380
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #523"
    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: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    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.7% · Safe to merge
    19.7%