← Back to Pull requests

Show budget performance for past months in Reports #6106

Open
unknown opened this pull request with 257 lines diff across 3 files
View on GitHub
unknown unknown commented on Dec 03, 2026 21:07 UTC
Author

Problem

Pick any past month in Reports and the budget performance tile says "No budget data", even when that month has a budget. ReportsController#calculate_budget_performance returns nil for every month except the current one.

The current month has the opposite bug. A budget with no category allocations shows 0%, as if you'd spent nothing.

Why it was current-month only

#276 added the guard back when "Monthly" always meant this month, so it hid nothing. Then #5298 linked month names to their own reports. Since then every past month hides its budget. I couldn't find an issue for it. I noticed when my September, October and November budgets vanished from Reports.

Changes

  • Budget performance works for any monthly report.

  • A month without category allocations shows "No budget data" instead of 0%.

  • New tests cover a past month with an allocation and a month without one.

  • The existing current-month test never created an allocation the report reads. It passed because 0% still renders "of budget used". Now it sets a real allocation.
  • Notes

    Budget.find_or_bootstrap creates an empty budget for a past month the first time you open its report. The Budgets page already does this when you navigate to a month, so I kept the same call.

    Quarterly, YTD, custom and all-time reports still have no budget tile. A budget covers one month and I didn't want to invent a multi-month rule here.

    Verification

    All 154 tests in test/controllers/reports_controller_test.rb pass in the devcontainer image. Without the controller change, the past-month test fails. Rubocop is clean on both files.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Monthly reports now show budget performance for the month being viewed, including past months.
    * Reports show no budget data when the selected month has no budget or its budget allocations are zero.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 257 lines (+192 / -65) across 3 files Reviewer: jjmata Review duration: 2492m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 257 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.332
    Real PR Conversation Timeline
    1 comments
    "Review active on #6106"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 39.1% (MEDIUM) · Higher = larger blast radius
    39.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: 46.7% · Lower = rushed or shallow review
    46.7%
    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.9% · Safe to merge
    20.9%