Skip to content

fix: baseline stars_count first bucket against startDate, not 0 (CM-1819) - #4791

Merged
themarolt merged 4 commits into
mainfrom
fix/CM-1819-stars-count-first-bucket
Sep 28, 2026
Merged

themarolt merged 4 commits into
mainfrom
fix/CM-1819-stars-count-first-bucket

Conversation

@themarolt

Copy link
Copy Markdown
Contributor

Summary

Fixes the Stars widget's "New" tab showing an inflated spike in the first bucket of any date range - stars_count.pipe now baselines the first bucket against the real cumulative total as of startDate instead of 0.

Changes

  • Added stars_count_baseline node: computes cumulative stars total as of startDate (mirrors stars_count_summary's existing github_at_start/gitlab_new logic).
  • stars_count_bucketed: pass the baseline as lagInFrame's own default argument instead of via coalesce() after the call - ClickHouse's lagInFrame already returns 0 (not NULL) for a missing prior row, so the previous coalesce(lagInFrame(...), baseline) pattern never triggered the fallback.
  • Wrapped the baseline scalar subquery in coalesce((SELECT baseline FROM stars_count_baseline), 0) to avoid a ClickHouse type mismatch (Nullable(Int64) vs Int64) when passed as lagInFrame's default.

Verified live on production (lfx_insights) against two independent projects (k8s, heroic-games-launcher) - first bucket now matches expected deltas instead of the pre-range cumulative total.

Type of change

  • Bug fix

JIRA ticket

https://linuxfoundation.atlassian.net/browse/CM-1819

…819)

Signed-off-by: Uroš Marolt <uros@marolt.me>
Copilot AI balanced review requested due to automatic review settings September 28, 2026 16:50
@cursor

cursor Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Tinybird analytics-only change to bucketed star deltas; no app or API contract changes beyond corrected chart values.

Overview
Fixes CM-1819: bucketed “new stars” in stars_count.pipe no longer treats the first period as if cumulative stars started at zero, which inflated the first bucket with all pre-range history (e.g. Stars widget “New” tab spike).

Adds stars_count_baseline, a scalar cumulative total as of startDate (GitHub snapshot totals + GitLab star events through startDate, aligned with stars_count_summary). stars_count_bucketed subtracts each bucket’s cumulative total from the prior bucket using lagInFrame, with that baseline as the default for the first row—replacing coalesce(lagInFrame(...), 0), which never applied because ClickHouse returns 0 rather than NULL when there is no prior row. Pipe docs now describe startDate baselining and note that incomplete snapshot backfill can still mis-attribute pre-range stars for affected repos.

Reviewed by Cursor Bugbot for commit fbbff7f. 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.

Copilot review overview

🟡 Changes recommended

The documentation incorrectly claims the fix works regardless of snapshot backfill completeness.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes inflated first-bucket star deltas by baselining against cumulative stars at startDate.

Changes:

  • Adds a GitHub and non-GitHub baseline node.
  • Uses the baseline as lagInFrame’s default value.
  • Updates pipe documentation.
File Description
services/​libs/​tinybird/​pipes/​stars_count.pipe Corrects first-bucket star calculations and documents the behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread services/libs/tinybird/pipes/stars_count.pipe Outdated
Copilot AI review requested due to automatic review settings September 28, 2026 18:06

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 review overview

🟢 Approval recommended

The baseline logic matches existing summary semantics, and the previous documentation concern is addressed.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@themarolt
themarolt merged commit 764f9c8 into main Sep 28, 2026
15 checks passed
@themarolt
themarolt deleted the fix/CM-1819-stars-count-first-bucket branch September 28, 2026 18:17
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