Skip to content

fix: count bot-merged prs and bot-closed issues in development widgets - #2412

Merged
joanagmaia merged 2 commits into
mainfrom
fix/issue-790-dev-prs-issues-bots
Oct 20, 2026
Merged

joanagmaia merged 2 commits into
mainfrom
fix/issue-790-dev-prs-issues-bots

Conversation

@joanagmaia

@joanagmaia joanagmaia commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Symptom

The Pull requests widget on the Development tab shows 0 merged PRs for repositories that merge through a bot. istio/istio reported 1,305 opened and 0 merged over the past year (#2369), even though GitHub lists thousands of merged PRs.

Root cause

The opened, merged and closed counts come from activities_count, which reads the bot-filtered activity buckets. A merge activity belongs to the account that clicked merge. istio merges every PR with its Prow bot, istio-testing, so every istio merge is dropped before the widget counts it. The Development docs say these metrics include bots, but only the widgets built on pull_requests_analyzed did. Issues resolution had the same gap: an issue closed by a stale bot did not count as closed.

Change

  • The Pull requests widget counts opened, merged and closed PRs with the new pull_requests_count pipe, which reads pull_requests_analyzed, the same table its average velocity already uses. Each PR is counted once, and a PR a bot merged counts as merged.
  • The Issues resolution widget counts opened and closed issues with the new issues_count pipe, which reads issues_analyzed. That table now includes issues opened or closed by bots.
  • The public API routes /development/pull-requests and /development/issues-resolution make the same switch, so the API and the widgets return the same numbers.
  • Docs: the Development note now lists which widgets include bots (the pull request and issue metrics) and which describe people and exclude them (commit activities, active days, contribution time distribution, code review engagement). The health score docs now say that issue resolution and PR merge health include bot activity.

istio/istio over the past year, checked against production data:

Today With this change
PRs opened 1,305 3,152
PRs merged 0 2,016
PRs closed not checked 636
Issues opened 700 924
Issues closed 185 972

Deploy order

This PR depends on linuxfoundation/crowd.dev#5028, which adds the pull_requests_count and issues_count pipes and the bot-inclusive issues_analyzed. Push those pipes to the production Tinybird workspace before deploying this PR. Until then the two widgets and API routes have no pipe to call. Both pipes declare read access for the insights app token, so no separate grant is needed.

Closes linuxfoundation/lfx-cdp-insights-ops#790

Copilot AI balanced review requested due to automatic review settings October 19, 2026 16:03
@cursor

cursor Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes upstream data sources and query parameters for core Development metrics, so reported counts can shift sharply and the release depends on Tinybird pipes being deployed first.

Overview
Switches Development PR and issue widgets (and matching v1-alpha API routes) from bot-filtered activities_count to lifecycle-based Tinybird pipes, so bot merges and bot closes are counted as documented.

The Pull requests path now calls pull_requests_count with state (opened | merged | closed) instead of aggregating multiple ActivityTypes on activities_count. The Issues resolution path uses issues_count with state opened/closed instead of issue activity types. Count fields move from activityCount to pullRequestCount / issueCount; the public response shapes stay the same.

The frontend Tinybird data layer and tests/mocks are updated in parallel so widgets and API stay aligned. Docs clarify which Development metrics include bots (PR/issue-related widgets and health-score issue/PR sub-signals) versus people-only metrics.

Deploy note: requires pull_requests_count, issues_count, and bot-inclusive issues_analyzed in production Tinybird before this ships.

Reviewed by Cursor Bugbot for commit 5861eaa. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

🔵 Needs a closer look

Human confirmation is needed that the dependent Tinybird pipes are deployed and application tokens have the required read permissions.

No open issues 🎉

What changed in this PR

Updates Development widgets and matching public API routes to count bot-inclusive pull request and issue lifecycle data.

Changes:

  • Replaces activity counts with dedicated Tinybird count pipes.
  • Updates tests and mocks for the new response fields.
  • Clarifies bot inclusion in Development and health-score documentation.
File Description
frontend/​server/​mocks/​tinybird-pull-requests-response.mock.ts Uses pullRequestCount in fixtures.
frontend/​server/​mocks/​tinybird-issues-response.mock.ts Uses issueCount in fixtures.
frontend/​server/​data/​tinybird/​development/​pull-requests.ts Fetches PR lifecycle counts by state.
frontend/​server/​data/​tinybird/​development/​pull-requests.test.ts Updates query and response expectations.
frontend/​server/​data/​tinybird/​development/​issues-resolution.ts Fetches issue lifecycle counts by state.
frontend/​server/​data/​tinybird/​development/​issues-resolution.test.ts Updates summary count expectations.
frontend/​docs/​metrics/​health-score/​index.md Documents bot-inclusive health metrics.
frontend/​docs/​metrics/​development/​index.md Clarifies which metrics include bots.
api/​tests/​development-pull-requests.test.ts Updates PR endpoint integration tests.
api/​tests/​development-issues-resolution.test.ts Updates issue endpoint integration tests.
api/​src/​versions/​v1-alpha/​development/​pull-requests.ts Switches API counts to the PR pipe.
api/​src/​versions/​v1-alpha/​development/​issues-resolution.ts Switches API counts to the issue pipe.

Review effort: Balanced

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the documented upstream deployment order.

Summary

Switches the Development widgets and public API routes from activity counts to issue and pull request counts that include bot actions.

  • Pull-request counts include merges and closures done by bots.
  • Issue counts include openings and closures done by bots.

Reviews (2) · Last reviewed commit: "Merge branch 'main' into fix/issue-790-d..." · Reviewed by Greptile

@joanagmaia
joanagmaia requested a review from gaspergrom October 19, 2026 17:41

@gaspergrom gaspergrom left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. I checked the call parameters (state, repos, platform, granularity, project/collectionSlug) and the response fields (pullRequestCount, issueCount) against the pull_requests_count and issues_count pipes in crowd.dev#5028, and they match. No other widget or route still reads activities_count for PR or issue opened/merged/closed counts. Merge after the pipes are deployed.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 11:25

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.

🔵 Needs a closer look

Production deployment of the required upstream Tinybird pipes needs human confirmation before rollout.

No open issues 🎉

Review effort: Balanced

@joanagmaia
joanagmaia merged commit 69c2097 into main Oct 20, 2026
16 checks passed
@joanagmaia
joanagmaia deleted the fix/issue-790-dev-prs-issues-bots branch October 20, 2026 11:39
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.

3 participants