Skip to content

Fix #25595: Locations details show all level - #25961

Merged
crazytonyli merged 4 commits into
trunkfrom
bugfix/25595-locations-show-all-level
Nov 19, 2026
Merged

crazytonyli merged 4 commits into
trunkfrom
bugfix/25595-locations-show-all-level

Conversation

@crazytonyli

Copy link
Copy Markdown
Contributor

Description

Switch to "Regions" and view all:

Before After
before-locations-title regions-title

@crazytonyli
crazytonyli requested a review from jkmassel September 1, 2026 00:05
@crazytonyli crazytonyli added this to the 27.3 milestone Sep 1, 2026
@wpmobilebot

Copy link
Copy Markdown
Contributor
App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number34092
VersionPR #25961
Bundle IDorg.wordpress.alpha
Commit0d0bce0
Installation URL10mgqd810ts1g
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
App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number34092
VersionPR #25961
Bundle IDcom.jetpack.alpha
Commit0d0bce0
Installation URL6d5gi5jn9631o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot wpmobilebot modified the milestones: 27.3, 27.4 Sep 20, 2026
@wpmobilebot

Copy link
Copy Markdown
Contributor

Version 27.3 has now entered code-freeze, so the milestone of this PR has been updated to 27.4.

@wpmobilebot wpmobilebot modified the milestones: 27.4, 27.5 Oct 20, 2026
@wpmobilebot

Copy link
Copy Markdown
Contributor

Version 27.4 has now entered code-freeze, so the milestone of this PR has been updated to 27.5.

The Show All screen rebuilt its view model from only the item and metric,
resetting the location level, device breakdown, and UTM grouping to their
defaults. Pass the card's options through so the screen loads the same
data the card was showing.

Fixes #25595
The screen and its CSV export now use Countries, Regions, or Cities as
the title instead of Locations, so the selected level is visible. Other
item types keep their item title.
@crazytonyli
crazytonyli force-pushed the bugfix/25595-locations-show-all-level branch from 0d0bce0 to 3a67b95 Compare November 18, 2026 23:16
@crazytonyli
crazytonyli requested review from jkmassel and removed request for jkmassel November 19, 2026 00:25

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

From Claude: the level fix works in the app: Show All for Regions now shows region rows under a "Regions" title. One problem it introduces is noted inline: on Show All, an unneeded country request can turn a loaded list into an error.

self._viewModel = StateObject(
wrappedValue: TopListViewModel(
configuration: configuration,
options: selection.options,

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.

Finding from Claude:

With Regions or Cities selected, the Show All screen can show an error even though the list it needs loaded fine.

What happens

  • Now that Show All keeps the card's level, the view model also requests every country to build map data (TopListViewModel.swift:180-186).
  • Only the card draws that map (countriesMapData is read only at TopListCard.swift:110), so on Show All this request is never needed. It also has no size limit there (fetchLimit: nil).
  • If that request fails, the catch sets data = nil, and the regions list that did load is thrown away.
  • Before this PR, Show All always used Countries, so this extra request never happened there.

Who is affected
Anyone who opens Show All for Regions or Cities on a slow or flaky connection. Everyone else pays for an extra request with no size limit each time the screen loads (two with a comparison period).

What they see
The error state under a "Regions" title.

Show All titled Regions showing ‘The operation couldn’t be completed. (NSURLErrorDomain error -1001.)’

Steps to reproduce

  1. Open Stats → Traffic on a site with visitors from several regions (mobile.blog was used).
  2. On the Locations card, switch the level to Regions and wait for it to load.
  3. Tap Show All.
  4. Make the all-countries request fail. For the screenshot, a temporary local change in StatsService.getTopListData threw URLError(.timedOut) for .locations + .countries + limit == nil. Only the Show All screen sends that combination, and the regions request was left untouched.

Suggested fix
Only fetch map data when the view model drives a card. For example, skip it when fetchLimit == nil, or pass an explicit flag. Making a failed map request leave data alone would also avoid the error state. Once that's in, the new test could assert the full request list ([.regions] on Show All) instead of .first, so a change to the map request gets caught.

How this was checked

  • Jetpack Debug build of 3a67b951bf on an iOS 27.2 simulator, signed in to WordPress.com. Without the temporary change, Show All for Regions loads correctly (title "Regions", region rows).
  • With the temporary change: the screenshot above.
  • A unit test against the same commit, using a fake service whose countries request throws: the requests were [regions, countries] with limits [nil, nil], then data == nil and loadingError was set. The test is below and was not committed.
Unit test used
@Test("A failed map fetch hides the loaded regions list on Show All")
func mapFetchFailureHidesList() async throws {
    let service = RecordingStatsService(failCountries: true) // throws URLError(.timedOut) for .countries
    let calendar = Calendar.mock()
    let dateRange = StatsDateRange(
        interval: calendar.makeDateInterval(for: .today),
        component: .day,
        comparison: .off,
        calendar: calendar
    )
    let viewModel = TopListViewModel(
        configuration: TopListCardConfiguration(item: .locations, metric: .views),
        options: TopListItemOptions(locationLevel: .regions),
        dateRange: dateRange,
        service: service,
        fetchLimit: nil // as TopListScreenView passes it
    )
    viewModel.onAppear()
    try await waitUntil { !viewModel.isLoading }

    #expect(await service.requestedLocationLevels == [.regions, .countries]) // passes
    #expect(viewModel.data == nil)          // passes: the loaded regions list is discarded
    #expect(viewModel.loadingError != nil)  // passes
}

Output: levels=[regions, countries] limits=[nil, nil] data=nil error=NSURLErrorDomain Code=-1001

Only the Locations card draws the countries map. Show All now keeps the
card's Regions or Cities level, so it also sent an unlimited request for
all countries. If that request failed, the loaded list was replaced by an
error. The view model now loads map data only when its owner asks for it.
@crazytonyli
crazytonyli requested a review from jkmassel November 19, 2026 03:21
@dangermattic

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is assigned to the milestone 27.5. This milestone is due in less than 4 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@crazytonyli
crazytonyli added this pull request to the merge queue Nov 19, 2026
Merged via the queue into trunk with commit 787d5bd Nov 19, 2026
21 checks passed
@crazytonyli
crazytonyli deleted the bugfix/25595-locations-show-all-level branch November 19, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants