Skip to content

Add Latest Post Summary card and per-post stats to New Stats - #23178

Draft
nbradbury wants to merge 9 commits into
trunkfrom
newstats/latest-post-summary
Draft

Add Latest Post Summary card and per-post stats to New Stats#23178
nbradbury wants to merge 9 commits into
trunkfrom
newstats/latest-post-summary

Conversation

@nbradbury

@nbradbury nbradbury commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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.

⚠️ Not mergeable yet. This depends on the hash of this wordpress-rs PR which is still unpublished.

Testing instructions

Latest Post Summary card:

  1. Open Stats → Insights on a WP.com or Jetpack site with published posts.
  • The summary card appears third by default, showing the newest published post with its date
  • Views, likes and comments match old Stats' Latest Post Summary for the same post
  1. Use the card menu to remove it, re-add it via "Add card", and move it up/down.
  • Order persists across an app restart

Per-post stats screen:

  1. Tap the card.
  • Post title and date match the card (both formatted, e.g. "Aug 4, 2026")
  • Chart, Recent Weeks, Months and Years, and Avg. Views Per Day match old Stats' post detail for the same post
  1. Rotate the device.
  • Content is retained; no refetch and no return to the loading state

Edge case:

  1. Enable airplane mode and tap Retry.
  • The card shows its error state and recovers when connectivity returns
post.webm

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

dangermattic commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator
5 Errors
🚫 Please add tests for class LatestPostDataSource (or add unit-tests-exemption label to ignore this).
🚫 Please add tests for class LatestPostViewModel (or add unit-tests-exemption label to ignore this).
🚫 Please add tests for class PostStatsDetailViewModel (or add unit-tests-exemption label to ignore this).
🚫 Please add tests for class StatsLatestPostUseCase (or add unit-tests-exemption label to ignore this).
🚫 This PR includes a PR version of wordpress-rs (1489-ae229223a02c28bcb0b729b680201000634d8158). Please merge the corresponding wordpress-rs PR and update to a trunk version before merging.
1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot

wpmobilebot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Project manifest changes for WordPress

The following changes in the WordPress's merged AndroidManifest.xml file were detected (build variant: jetpackRelease):

--- ./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 Artifacts tab and audit the files.

@wpmobilebot

wpmobilebot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Project manifest changes for WordPress

The following changes in the WordPress's merged AndroidManifest.xml file were detected (build variant: wordpressRelease):

--- ./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 Artifacts tab and audit the files.

@wpmobilebot

wpmobilebot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

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

@nbradbury nbradbury added Stats [Status] Stale Do Not Merge PR shouldn't be merged, failing the build labels Aug 6, 2026
@stale stale Bot removed the [Status] Stale label Aug 6, 2026
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.
@wpmobilebot

Copy link
Copy Markdown
Contributor

Project dependencies changes

list
! 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 (*)

@wpmobilebot

wpmobilebot commented Aug 6, 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
Versionpr23178-55d2f54
Build Number1498
Application IDcom.jetpack.android.prealpha
Commit55d2f54
Installation URL38ikcts72o13g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot

wpmobilebot commented Aug 6, 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
Versionpr23178-55d2f54
Build Number1498
Application IDorg.wordpress.android.prealpha
Commit55d2f54
Installation URL3fmig4i621mr0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge PR shouldn't be merged, failing the build Stats

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants