Add Latest Post Summary card and per-post stats to New Stats - #23178
Add Latest Post Summary card and per-post stats to New Stats#23178nbradbury wants to merge 9 commits into
Conversation
New Stats had no per-post surface: old stats' Latest Post Summary insight and its post detail screen are both FluxC-backed and were never ported. The new wordpress-rs per-post stats endpoint makes the Compose versions possible, so both are added here. The endpoint is not published yet, so the build consumes wordpress-rs from a local composite build via `localWordPressRsPath`. That has to become a version bump before this can merge.
Generated by 🚫 Danger |
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/jetpackRelease/base_manifest.txt 2026-08-06 19:25:28.961470886 +0000
+++ ./build/reports/diff_manifest/WordPress/jetpackRelease/head_manifest.txt 2026-08-06 19:25:33.325517560 +0000
@@ -405,6 +405,10 @@
android:exported="false"
android:theme="@style/WordPress.NoActionBar" />
<activity
+ android:name="org.wordpress.android.ui.newstats.poststats.PostStatsDetailActivity"
+ android:exported="false"
+ android:theme="@style/WordPress.NoActionBar" />
+ <activity
android:name="org.wordpress.android.ui.newstats.subscribers.subscriberslist.SubscribersListDetailActivity"
android:exported="false"
android:theme="@style/WordPress.NoActionBar" />Go to https://buildkite.com/automattic/wordpress-android/builds/27857/canvas?sid=019fd886-a6e0-41e9-a10b-3c6babf72391, click on the |
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/wordpressRelease/base_manifest.txt 2026-08-06 19:25:27.140337950 +0000
+++ ./build/reports/diff_manifest/WordPress/wordpressRelease/head_manifest.txt 2026-08-06 19:25:31.955002157 +0000
@@ -217,6 +217,10 @@
android:exported="false"
android:theme="@style/WordPress.NoActionBar" />
<activity
+ android:name="org.wordpress.android.ui.newstats.poststats.PostStatsDetailActivity"
+ android:exported="false"
+ android:theme="@style/WordPress.NoActionBar" />
+ <activity
android:name="org.wordpress.android.ui.newstats.subscribers.subscriberslist.SubscribersListDetailActivity"
android:exported="false"
android:theme="@style/WordPress.NoActionBar" />Go to https://buildkite.com/automattic/wordpress-android/builds/27857/canvas?sid=019fd886-a6df-4451-9e6e-d00792b819f6, click on the |
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
The tab had two post-detail destinations: the Latest Post card opened the Compose screen while Posts & Pages rows still opened the legacy one. The blocker was the "Home page / Archives" row, which reports id 0 and has no post behind it. wordpress-rs now serves stats for post id 0, returning no post, discussion or like_count for it, so `PostViewsData.post` is nullable and the home page shows its views without the post-only sections. Both row call sites route to the Compose screen, passing the row's title so the home page has a heading and posts have one while loading.
Comparing the two screens side by side, the new one had drifted: it abbreviated from 1,000 where old stats abbreviates from 10,000 and groups below that, so 1,986 views read as "2.0K"; its tables had no column headers or dividers; and its chart had no axes at all. It also showed all-time views where old stats shows a selected day. The screen now tracks a selected day with arrows to step through the history, and reports that day's views and the change against the day before, over a two-week chart with value and date axes and the day highlighted. Serving the selected day needs the full view history rather than a trailing window, which lets `recentDays` drop out of the data source, repository and use case; the card takes its own trailing week instead.
Routing Posts & Pages rows to the Compose screen left ActivityNavigator.openPostDetailStats with no callers. It was added a week ago for exactly those two call sites, and it carried the navigator's only use of SelectedSiteRepository along with statsDetailItemType and that helper's test. Removing it drops the DI edge and takes away a public method that silently opened the old stats screen, one autocomplete away from a third entry point.
Two things were visible. The header formatted views through StatsLabeledValue, which abbreviated from 1,000, while the tables below abbreviated from 10,000, so 4,600 lifetime views read as "4.6K" in one place and "4,600" in another. formatStatValue now takes the threshold as a parameter, the way old stats' toFormattedString does, and the screen applies one threshold throughout. The chart window was derived from the selected day, which forced the highlight onto the last bar and shrank the chart to four bars near the start of a post's history. It is now a fixed trailing window with the highlight moving inside it and the arrows clamped to it, as the old screen does. That also retires a chartDays getter that copied the whole view history on every read to keep fourteen entries. The rest is smaller: the chart's values and axis labels are remembered so they stop invalidating Vico's own remembers and no date parsing happens on the draw path; the selected bar has its own colour token instead of borrowing the one that means "views went down"; the card passes its title to the click handler rather than having the caller downcast the state; and post id 0, the home page, no longer doubles as the missing-extra default.
The old card showed one and the new one didn't. The per-post stats response carries no image -- it has the post's ids, dates, slug and status but no media -- so the image comes from the post lookup instead: that call now asks for FEATURED_MEDIA alongside the id, and resolves the attachment id to a URL through the media endpoint. The media call is made only when the post has a featured image, and a failure there costs the thumbnail rather than the card, since the stats are what the card is for.
The per-post stats endpoint is still unreleased, so the branch was consuming wordpress-rs from a local composite build. That only works on a machine with the checkout, which is why every CI job failed to compile. Pins the artifact CI published for wordpress-rs#1489 instead. The commit is the PR's head, so the API matches what this branch was developed against. Still needs a final bump to a released version once that PR lands.
Project dependencies changeslist! Upgraded Dependencies
rs.wordpress.api:android:1489-ae229223a02c28bcb0b729b680201000634d8158, (changed from 0.6.0)
rs.wordpress.api:kotlin:1489-ae229223a02c28bcb0b729b680201000634d8158, (changed from 0.6.0)tree +--- project :libs:fluxc
-| \--- rs.wordpress.api:android:0.6.0
-| +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-| +--- com.squareup.okhttp3:okhttp-tls:5.4.0
-| | +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
-| | +--- com.squareup.okio:okio:3.17.0 (*)
-| | \--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-| +--- net.java.dev.jna:jna:5.19.1
-| +--- rs.wordpress.api:kotlin:0.6.0
-| | +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
-| | +--- com.squareup.okhttp3:okhttp-tls:5.4.0 (*)
-| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
-| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
+| \--- rs.wordpress.api:android:1489-ae229223a02c28bcb0b729b680201000634d8158
+| +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| +--- com.squareup.okhttp3:okhttp-tls:5.4.0
+| | +--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.4.10 (*)
+| | +--- com.squareup.okio:okio:3.17.0 (*)
+| | \--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| +--- net.java.dev.jna:jna:5.19.1
+| +--- rs.wordpress.api:kotlin:1489-ae229223a02c28bcb0b729b680201000634d8158
+| | +--- com.squareup.okhttp3:okhttp:5.4.0 (*)
+| | +--- com.squareup.okhttp3:okhttp-tls:5.4.0 (*)
+| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 -> 1.11.0 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
+| \--- org.jetbrains.kotlin:kotlin-stdlib:2.3.21 -> 2.4.10 (*)
-\--- rs.wordpress.api:android:0.6.0 (*)
+\--- rs.wordpress.api:android:1489-ae229223a02c28bcb0b729b680201000634d8158 (*) |
|
|
|
|
With the version pinned to the artifact CI publishes for the rs PR, nothing needs the includeBuild path any more. Restores both files to trunk, leaving the branch's only build change as the one-line version pin.
formatStatAverage did what the existing formatStatValue(Double) overload already does, and which Year In Review's detail screen already uses for its averages. Averages of a thousand or more lose their grouping separator as a result, which is how every other Double stat in the package renders. postType lost its only reader when the Posts & Pages rows moved to the Compose screen, which needs just an id and a title. It was still carried from the data source through the repository into two UI states, one of them Parcelable.


Description
Adds a Latest Post Summary card to the New Stats Insights tab, and a Compose per-post stats screen it drills into — both on wordpress-rs rather than FluxC. The card shows the newest published post's views, likes and comments with a seven-day sparkline; the detail screen adds a daily-views chart, recent weeks, months and years, and average views per day.
Testing instructions
Latest Post Summary card:
Per-post stats screen:
Edge case:
post.webm