Skip to content

Restore Pull Requests metrics in team-scoped view by enriching team reportData with PR day totals - #450

Draft
karpikpl with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-team-level-pull-requests
Draft

Restore Pull Requests metrics in team-scoped view by enriching team reportData with PR day totals#450
karpikpl with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-team-level-pull-requests

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Organization scope returned Pull Requests metrics, but team scope rendered the PR tab as empty because team aggregation preserved usage totals while dropping day_totals[].pull_requests. This change aligns team responses with org responses so the PR tab has the data it expects.

  • Root cause

    • Team-scoped metrics are built from per-user records (aggregateTeamMetrics), which do not include PR aggregates.
    • PullRequestViewer reads PR data from reportData[].pull_requests; in team scope that field was missing.
  • Backend change: team PR enrichment

    • Added enrichTeamReportWithPullRequests(...) in shared/utils/metrics-util-v2.ts.
    • For team requests, after per-user aggregation, fetches the team report via fetchLatestReport(...) and merges pull_requests into matching day_totals by day.
    • Applies in all team paths:
      • historical mode (DB-backed team aggregation),
      • historical mode API fallback,
      • direct API mode.
    • If PR report data is unavailable, behavior degrades safely to existing non-PR output.
  • Regression coverage

    • Extended tests/metrics-util-v2-team-path.spec.ts with a focused test asserting team reportData includes pull_requests when provided by the report API.
const enrichedReport = await enrichTeamReportWithPullRequests(
  report,
  options,
  event.context.headers,
  identifier
);
return buildFilteredResult(enrichedReport, options);

Copilot AI self-assigned this Jul 31, 2026
Copilot AI review requested due to automatic review settings July 31, 2026 22:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Co-authored-by: karpikpl <3539908+karpikpl@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI changed the title [WIP] Fix pull request data rendering in team view Restore Pull Requests metrics in team-scoped view by enriching team reportData with PR day totals Jul 31, 2026
Copilot AI requested a review from karpikpl July 31, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

This appears to be a GitHub issue related to the Pull Requests tab.

3 participants