Skip to content

feat: growth deltas in analytics overview (#31)#35

Merged
jdwit merged 2 commits into
mainfrom
feat/analytics-growth-deltas
Jun 13, 2026
Merged

feat: growth deltas in analytics overview (#31)#35
jdwit merged 2 commits into
mainfrom
feat/analytics-growth-deltas

Conversation

@jdwit

@jdwit jdwit commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Closes #31.

What

analytics overview now shows a period-over-period growth trend by default: each metric is compared to the previous equal-length window and rendered with a coloured percent change.

views        12.0K  (+20%)
watch time   100 hours  (+0%)
avg duration 3:00  (-10%)
likes        770  (+10%)

green for positive, red for negative.

Behaviour

  • Queries the previous window [today-2*days, today-days] for the same metrics and computes the percent change for views, estimatedMinutesWatched, averageViewDuration, likes, comments.
  • --no-compare reproduces the previous single-window output (and skips the extra query). The flag is --compare/--no-compare, default on, leaving room for a future --compare-to.
  • subscribersGained/Lost are flows; they keep their existing +/- counts without a delta.
  • JSON output gains previous (the prior window's metrics) and pct_change (percent change per metric). When there is no prior-window baseline (previous == 0), pct_change is null and the table shows (new) instead of dividing by zero.

Cost

One extra Analytics API query per overview when comparing. The Analytics API is separate from the Data API quota and cheap, so the impact is negligible.

Tests

Four new tests cover the table deltas, JSON previous/pct_change, --no-compare (asserts only one query is issued), and the zero-previous guard. Full suite: 252 passing, ruff clean.

Note

Following the issue's window sketch, the previous window's end date equals the current window's start date, so the boundary day is shared (matching the existing inclusive single-window semantics). Easy to tighten later if exact non-overlapping windows are preferred.

jdwit added 2 commits June 13, 2026 20:38
Closes #31. overview now queries the previous equal-length window by
default and shows the percent change per metric (green up, red down).
--no-compare reproduces the single-window output. JSON gains previous
and pct_change fields; previous == 0 yields a null pct_change / (new)
marker instead of dividing by zero.
Previous window now ends the day before the current window starts, so the
two equal-length windows do not double-count the shared day.
@jdwit jdwit merged commit 926ac01 into main Jun 13, 2026
7 checks passed
@jdwit jdwit deleted the feat/analytics-growth-deltas branch June 13, 2026 18:44
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.

Add period-over-period growth deltas to analytics overview

1 participant