CMM-1936: Add Insights tab with Year in Review card#22666
CMM-1936: Add Insights tab with Year in Review card#22666
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Populate the Insights tab with card management (add, remove, move) mirroring the Traffic tab architecture. Add Year in Review as the first Insights card, fetching yearly summaries (posts, words, likes, comments) via the wordpress-rs statsInsights endpoint. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update the card title to show "YEAR in review" instead of a generic title. Replace the table layout with a 2x2 grid of mini cards, each displaying an icon, label, and formatted value for Posts, Words, Likes, and Comments, matching the web design. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add a detail screen showing all years with full stats (posts, comments, avg comments/post, likes, avg likes/post, words, avg words/post). The card shows the most recent year and a "View all" link when multiple years are available. Years are sorted newest first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ow All Ensure the current year is always present in the data, adding it with zero values if not returned by the API. The Show All footer is now always visible regardless of the number of years available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use resource string for exception errors instead of raw e.message - Add duplicate guard in addCard() - Change Error from data class to class to fix lambda equality - Use Year.now() per-call instead of cached static val - Fix isValidConfiguration to check for null entries - Remove 0dp Spacer from detail screen - Add StatsFormatterTest with 12 tests - Add repository moveCard and addCard duplicate tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Generated by 🚫 Danger |
|
Claude finished @adalpari's task in 3m 28s —— View job Code Review: CMM-1936 – Insights Tab with Year in Review Card
Overall the PR is well-structured and follows the established Traffic-tab patterns closely. The code is clean, the test coverage is solid, and the architecture is consistent. Below are the issues worth addressing before merging. Bugs / Correctness1.
When // loadDataInternal – sets true on success but never resets on failure
is InsightsResult.Success -> {
isLoadedSuccessfully = true // ← never reset on subsequent failure
...
}Fix: reset 2. Race condition in
Every mutation method ( suspend fun removeCard(siteId: Long, cardType: InsightsCardType) =
withContext(ioDispatcher) {
val current = getConfiguration(siteId) // read
...
saveConfiguration(siteId, ...) // write
}
Recommended fix: use a 3.
private val siteId: Long
get() = selectedSiteRepository.getSelectedSite()?.siteId ?: 0LIf Design / API Inconsistency4.
// All other methods:
suspend fun fetchStatsVisits(siteId: Long, ...): ...
// Insights:
suspend fun fetchStatsInsights(siteId: String): StatsInsightsDataResultThe conversion to UX Issues5. Period selector (date/calendar toolbar button) is visible on the Insights tab
The Minor Issues6.
When an invalid config is found and reset, 7.
8. Loading shimmer has no accessibility semantics
The shimmer Test CoverageThe test suite is comprehensive and covers the key scenarios well (success, error, retry, refresh,
Summary
|
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/wordpressRelease/base_manifest.txt 2026-03-09 17:02:48.377165720 +0000
+++ ./build/reports/diff_manifest/WordPress/wordpressRelease/head_manifest.txt 2026-03-09 17:03:06.407203272 +0000
@@ -203,6 +203,10 @@
<activity
android:name="org.wordpress.android.ui.newstats.authors.AuthorsDetailActivity"
android:exported="false"
+ android:theme="@style/WordPress.NoActionBar" />
+ <activity
+ android:name="org.wordpress.android.ui.newstats.yearinreview.YearInReviewDetailActivity"
+ android:exported="false"
android:theme="@style/WordPress.NoActionBar" /> <!-- Account activities -->
<activity
android:name="org.wordpress.android.ui.main.MeActivity"Go to https://buildkite.com/automattic/wordpress-android/builds/25372/canvas?sid=019cd383-1bb6-4fe1-88aa-dede8de9dfed, click on the |
Project manifest changes for WordPressThe following changes in the --- ./build/reports/diff_manifest/WordPress/jetpackRelease/base_manifest.txt 2026-03-09 17:02:57.130784216 +0000
+++ ./build/reports/diff_manifest/WordPress/jetpackRelease/head_manifest.txt 2026-03-09 17:03:12.870816913 +0000
@@ -395,6 +395,10 @@
<activity
android:name="org.wordpress.android.ui.newstats.authors.AuthorsDetailActivity"
android:exported="false"
+ android:theme="@style/WordPress.NoActionBar" />
+ <activity
+ android:name="org.wordpress.android.ui.newstats.yearinreview.YearInReviewDetailActivity"
+ android:exported="false"
android:theme="@style/WordPress.NoActionBar" /> <!-- Account activities -->
<activity
android:name="org.wordpress.android.ui.main.MeActivity"Go to https://buildkite.com/automattic/wordpress-android/builds/25372/canvas?sid=019cd383-1bb8-4aac-87ac-2ec3e34bea9c, click on the |
Project dependencies changeslist! Upgraded Dependencies
rs.wordpress.api:android:1219-9cb722b47cbf8380f7e7fd40d076773e1f87cea0, (changed from trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2)
rs.wordpress.api:kotlin:1219-9cb722b47cbf8380f7e7fd40d076773e1f87cea0, (changed from trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2)tree +--- project :libs:fluxc
-| \--- rs.wordpress.api:android:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2
-| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| +--- com.squareup.okhttp3:okhttp-tls:5.3.2
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okio:okio:3.16.4 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.10 (*)
-| +--- net.java.dev.jna:jna:5.18.1
-| +--- rs.wordpress.api:kotlin:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2
-| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
-| | +--- com.squareup.okhttp3:okhttp-tls:5.3.2 (*)
-| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (*)
-| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
-| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
+| \--- rs.wordpress.api:android:1219-9cb722b47cbf8380f7e7fd40d076773e1f87cea0
+| +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| +--- com.squareup.okhttp3:okhttp-tls:5.3.2
+| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | +--- com.squareup.okio:okio:3.16.4 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.2.21 -> 2.3.10 (*)
+| +--- net.java.dev.jna:jna:5.18.1
+| +--- rs.wordpress.api:kotlin:1219-9cb722b47cbf8380f7e7fd40d076773e1f87cea0
+| | +--- com.squareup.okhttp3:okhttp:5.3.2 (*)
+| | +--- com.squareup.okhttp3:okhttp-tls:5.3.2 (*)
+| | +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2 (*)
+| | \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
+| \--- org.jetbrains.kotlin:kotlin-stdlib:2.1.21 -> 2.3.10 (*)
-\--- rs.wordpress.api:android:trunk-4fac42b1a262e93adcbc0cd0353aafa0369671d2 (*)
+\--- rs.wordpress.api:android:1219-9cb722b47cbf8380f7e7fd40d076773e1f87cea0 (*) |
…, siteId fallback, API type inconsistency - Reset isLoadedSuccessfully on error/exception so loadDataIfNeeded recovers after failed refresh - Add Mutex to InsightsCardsConfigurationRepository to prevent concurrent mutation races - Guard siteId in InsightsViewModel mutations to avoid operating with invalid 0L - Align fetchStatsInsights parameter from String to Long for interface consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Claude sugestions achieved here |
|
|
|
|
🤖 Build Failure AnalysisThis build has failures. Claude has analyzed them - check the build annotations for details. |
Card uses short labels (Words, Likes) without "Total" prefix. Detail screen uses exact web labels: Total posts, Total comments, Avg comments per post, Total likes, Avg likes per post, Total words, Avg words per post. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
nbradbury
left a comment
There was a problem hiding this comment.
Looks good! I'll approve this and it can be merged when Buildkite is feeling better ![]()







Description
Populates the Insights tab in the new stats screen with its first card: Year in Review.
This follows the same architecture as the Traffic tab: card management (add/remove/move), data layer, ViewModel pattern, and comprehensive tests.
What's included:
InsightsCardTypeenum,InsightsCardsConfiguration, andInsightsCardsConfigurationRepositoryfor card management with persistence via AppPrefsStatsDataSource.fetchStatsInsights()andStatsRepository.fetchInsights()for fetching yearly insights dataYearInReviewDetailActivityshowing all years with full stats (totals + averages) in a table layout, accessible via "View all" linkInsightsViewModelhandles add/remove/move card operations with the same pattern asNewStatsViewModelTesting instructions
NOTE: You will see the period selector in the Insights screen, but it's useless. I've not hidden it because I already hid it in this PR (waiting for the RS layer to be approved) and I don't want to create any conflict.
Year in Review card:
View all detail screen:
Screen_recording_20260309_170610.mp4