Skip to content

CMM 1237 create cities and region stats card#22592

Merged
adalpari merged 58 commits intotrunkfrom
feat/CMM-1237-Create-location-and-region-stats-card
Feb 20, 2026
Merged

CMM 1237 create cities and region stats card#22592
adalpari merged 58 commits intotrunkfrom
feat/CMM-1237-Create-location-and-region-stats-card

Conversation

@adalpari
Copy link
Copy Markdown
Contributor

@adalpari adalpari commented Feb 12, 2026

Description

This PR adds Regions and Cities tabs to the Locations stats card alongside the existing Countries tab. I

Key changes:

  • New location types: Added segmented button selector (Countries / Regions / Cities) with lazy-fetching — each tab only fetches data when first selected
  • Map fix: Regions and Cities map data is now aggregated by country code so the GeoChart always renders at country resolution. The list below the map still shows individual
    regions/cities
  • Package rename: Moved countries package to locations to better reflect the broader scope
  • Detail screen: Updated CountriesDetailActivity to support all three location types with correct titles, data, and map rendering
  • Tests: Added tests for region/city aggregation, location type switching, detail data, and error handling

Testing instructions

Countries tab:

  1. Open Stats > Traffic tab
  2. Scroll to the Locations card (Countries tab selected by default)
  • Verify the map renders correctly with country-level fills
  • Verify the country list displays with flags, names, views, and change indicators
  1. Tap "Show all"
  • Verify the detail screen shows all countries with the map and summary card

Regions tab:

  1. Tap the "Regions" segment in the Locations card
  • Verify the map renders at country level (countries filled, no "map does not exist" error)
  • Verify the list below shows individual region names with their views
  1. Tap "Show all"
  • Verify the detail screen shows all regions

Cities tab:

  1. Tap the "Cities" segment in the Locations card
  • Verify the map renders at city level
  • Verify the list below shows individual city names with their views
  1. Tap "Show all"
  • Verify the detail screen shows all cities

Period switching:

  1. Switch between time periods (7 days, 30 days, etc.)
  • Verify each location type reloads correctly
  1. Switch location types after changing period
  • Verify lazy-fetch triggers correctly for unloaded types
Screen_recording_20260219_114330.mp4

…te-location-and-region-stats-card

# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/newstats/countries/CountriesViewModel.kt
@adalpari adalpari marked this pull request as ready for review February 19, 2026 11:57
@adalpari adalpari requested a review from nbradbury February 19, 2026 11:58
adalpari and others added 2 commits February 19, 2026 13:30
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 35.91613% with 703 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.15%. Comparing base (4328d05) to head (7a0c26b).
⚠️ Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
...ess/android/ui/newstats/locations/LocationsCard.kt 0.00% 303 Missing ⚠️
...roid/ui/newstats/datasource/StatsDataSourceImpl.kt 0.00% 111 Missing ⚠️
.../android/ui/newstats/repository/StatsRepository.kt 25.54% 100 Missing and 2 partials ⚠️
...roid/ui/newstats/locations/StatsGeoChartWebView.kt 0.00% 52 Missing ⚠️
...ndroid/ui/newstats/locations/LocationsViewModel.kt 85.58% 25 Missing and 22 partials ⚠️
...d/ui/newstats/locations/LocationsDetailActivity.kt 0.00% 38 Missing ⚠️
.../android/ui/newstats/datasource/StatsDataSource.kt 0.00% 28 Missing ⚠️
.../wordpress/android/ui/newstats/NewStatsActivity.kt 0.00% 17 Missing ⚠️
...ss/android/ui/newstats/authors/AuthorsViewModel.kt 89.47% 3 Missing and 1 partial ⚠️
...roid/ui/newstats/locations/LocationsCardUiState.kt 95.65% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            trunk   #22592      +/-   ##
==========================================
- Coverage   38.18%   38.15%   -0.04%     
==========================================
  Files        2254     2253       -1     
  Lines      113442   114096     +654     
  Branches    15802    15890      +88     
==========================================
+ Hits        43315    43528     +213     
- Misses      66534    66958     +424     
- Partials     3593     3610      +17     

☔ View full report in Codecov by Sentry.
📢 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.

Base automatically changed from fix/stats-cards-and-networking to trunk February 19, 2026 14:34
adalpari and others added 2 commits February 19, 2026 15:35
…-location-and-region-stats-card

# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/newstats/NewStatsActivity.kt
#	WordPress/src/main/java/org/wordpress/android/ui/newstats/countries/CountriesViewModel.kt
#	WordPress/src/main/java/org/wordpress/android/ui/newstats/mostviewed/MostViewedViewModel.kt
#	WordPress/src/test/java/org/wordpress/android/ui/newstats/NewStatsViewModelTest.kt
#	WordPress/src/test/java/org/wordpress/android/ui/newstats/countries/CountriesViewModelTest.kt
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adalpari
Copy link
Copy Markdown
Contributor Author

@nbradbury I've achieved some of the suggestions from here in: e7a02fb, ed8a978, and daaf68a

Fix 1 - WebView memory leak (StatsGeoChartWebView.kt:106-108): Added onRelease callback to AndroidView that calls webView.destroy() when the composable leaves composition.

  Fix 2 - Unvalidated lat/long (LocationsViewModel.kt:552-554): Changed the filter from a null check to toDoubleOrNull() != null, which validates that latitude and longitude
  are actually numeric before injecting them into JavaScript.

  Fix 3 - Missing exception handling (LocationsViewModel.kt and AuthorsViewModel.kt): Wrapped all repository fetch calls in try/catch(Exception) blocks that emit error UI
  states, matching the pattern used in MostViewedViewModel.

  Fix 4 - Redundant WebView reloads (StatsGeoChartWebView.kt:77, 93-104): Added a lastLoadedHtml state to track the previously loaded HTML. The update lambda now only calls
  webView.loadData() when the content actually changes.
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of comments, but nothing that should hold this PR up :shipit:

@adalpari adalpari enabled auto-merge (squash) February 20, 2026 09:05
@sonarqubecloud
Copy link
Copy Markdown

@adalpari adalpari merged commit 567e0e9 into trunk Feb 20, 2026
21 of 23 checks passed
@adalpari adalpari deleted the feat/CMM-1237-Create-location-and-region-stats-card branch February 20, 2026 09:37
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