Skip to content

New Stats: revamp period selector presets - #23287

Merged
adalpari merged 6 commits into
trunkfrom
adalpari/stats-preset-periods
Sep 3, 2026
Merged

New Stats: revamp period selector presets#23287
adalpari merged 6 commits into
trunkfrom
adalpari/stats-preset-periods

Conversation

@adalpari

@adalpari adalpari commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

TL;RD

This PR is reorganising the fixed periods in the new stats screen. Specifically, I'm adding "recent stats" periods and reorganising the menu.

share_4372459550836192762

Description

Revamps the period selector in the New Stats screen (Traffic tab).

  • Removes the Last 6 months preset.
  • Adds four calendar-aligned presets: Today, This Week, This Month, This Year (each running from the start of the current week/month/year up to today).
  • Groups the selector menu with separators:
    • Rolling presets: Last 7 days, Last 30 days, Last 12 months
    • Calendar presets: Today, This Week, This Month, This Year
    • Custom

Supporting changes so the new presets behave correctly across the chart, bottom-row totals, comparison ranges, labels, and back/forward navigation: the calendar windows derive their API granularity (day up to a month, month for This Year) and quantity from the actual window length. Today remains only in the calendar group (no longer duplicated at the top). Old-stats deep links keep mapping WEEK/MONTH to the rolling last-7/30-day periods.

Unit tests updated: the two Last6Months monthly-granularity tests were migrated to Last12Months, and duplicates that Last12Months already covered were removed.

Testing instructions

New Stats period selector:

  1. Open the app on a WordPress.com or Jetpack self-hosted site.
  2. Go to Stats → Traffic and tap the period selector at the top.
  • Smoke test the new "This ..." period entries.

Remove the "Last 6 months" preset and add calendar-aligned presets
(Today, This Week, This Month, This Year), grouped in the selector with
separators between the rolling presets, the calendar presets, and Custom.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dangermattic

dangermattic commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr23287-1eb7bb0
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit1eb7bb0
Installation URL2jdpo2u6va6ho
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr23287-1eb7bb0
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit1eb7bb0
Installation URL1m6ce9l2augbo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

The period selector revamp removed stats_period_last_6_months from the
default locale but left it in translation files, causing ExtraTranslation
lint errors. Remove the orphaned entries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.78761% with 59 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.93%. Comparing base (8c93d58) to head (1eb7bb0).
⚠️ Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
.../android/ui/newstats/repository/StatsRepository.kt 54.41% 26 Missing and 5 partials ⚠️
.../wordpress/android/ui/newstats/NewStatsActivity.kt 0.00% 15 Missing ⚠️
...a/org/wordpress/android/ui/newstats/StatsPeriod.kt 68.75% 3 Missing and 2 partials ⚠️
...roid/ui/newstats/viewsstats/ViewsStatsViewModel.kt 54.54% 1 Missing and 4 partials ⚠️
...rdpress/android/ui/newstats/util/StatsFormatter.kt 0.00% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #23287   +/-   ##
=======================================
  Coverage   37.92%   37.93%           
=======================================
  Files        2352     2352           
  Lines      128848   128925   +77     
  Branches    17909    17940   +31     
=======================================
+ Hits        48867    48907   +40     
- Misses      75983    76012   +29     
- Partials     3998     4006    +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@adalpari
adalpari marked this pull request as ready for review September 3, 2026 10:24
@adalpari
adalpari requested a review from nbradbury September 3, 2026 10:24
@nbradbury

Copy link
Copy Markdown
Contributor

@adalpari This is looking good, but Claude found a potential problem.

review-stats-preset-periods-2026-09-03.pdf

The ThisYear window is charted in day buckets early in January (when its
window is short) and month buckets otherwise, so keying drill-down and the
legend range off the period type mislabelled and mis-drilled the early-year
chart. Derive both from the chart's actual bucket unit instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari

adalpari commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

@adalpari This is looking good, but Claude found a potential problem.

review-stats-preset-periods-2026-09-03.pdf

Man, I was getting so mad at Claude because I already reviewed and fixed that twice!
But this time, it seems it was my bad :(

Now I understand what happened. The working tree already contains a fix for exactly these two review points (using the chart’s actual unit instead of the period type), but it is uncommitted and unpushed — so the PR the reviewer looked at (commit 45cb94d) still has the old period-type logic.

adalpari and others added 2 commits September 3, 2026 15:37
This Week/Month/Year now step to the full previous (or next) calendar
week/month/year instead of a same-length mirror of the partial window,
and continued paging stays aligned to whole calendar units. Rolling
presets keep their fixed-span step.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
On the first day of a calendar week/month/year the "This week/month/year"
window collapses to a single day identical to Today's window, so several
presets matched at once and snapToPreset picked Today first (it is listed
before the calendar presets). Paging forward onto the present then relabelled
the period "Today" and switched navigation from whole-unit steps to daily
steps.

Pass the navigated period into snapToPreset and, when multiple presets match,
prefer the one whose calendar unit matches the source, keeping the calendar
label and its whole-unit stepping.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adalpari

adalpari commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I introduced some extra-changes. So, it should be ready to go now!

@nbradbury nbradbury 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.

Looks good! :shipit:

@adalpari
adalpari enabled auto-merge (squash) September 3, 2026 16:59
@adalpari
adalpari merged commit b8157ff into trunk Sep 3, 2026
23 checks passed
@adalpari
adalpari deleted the adalpari/stats-preset-periods branch September 3, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants