From 2478aaeac1807b5c1968ba228426f3788cfe0e9a Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Dec 2024 06:19:33 -0500 Subject: [PATCH 1/3] Fix an issue with non-stable order in Posts and Pages in stats --- .../Classes/Stores/StatsPeriodStore.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/WordPress/Classes/Stores/StatsPeriodStore.swift b/WordPress/Classes/Stores/StatsPeriodStore.swift index ab7937953065..8686f4740f14 100644 --- a/WordPress/Classes/Stores/StatsPeriodStore.swift +++ b/WordPress/Classes/Stores/StatsPeriodStore.swift @@ -895,12 +895,24 @@ private extension StatsPeriodStore { } } - private func receivedPostsAndPages(_ postsAndPages: StatsTopPostsTimeIntervalData?, _ error: Error?) { + private func receivedPostsAndPages(_ data: StatsTopPostsTimeIntervalData?, _ error: Error?) { transaction { state in state.topPostsAndPagesStatus = error != nil ? .error : .success - if postsAndPages != nil { - state.topPostsAndPages = postsAndPages + if let data { + let sortedTopPosts = data.topPosts.sorted { lhs, rhs in + if lhs.viewsCount == rhs.viewsCount { + return lhs.title.localizedCaseInsensitiveCompare(rhs.title) == .orderedAscending + } + return lhs.viewsCount > rhs.viewsCount + } + state.topPostsAndPages = StatsTopPostsTimeIntervalData( + period: data.period, + periodEndDate: data.periodEndDate, + topPosts: sortedTopPosts, + totalViewsCount: data.totalViewsCount, + otherViewsCount: data.otherViewsCount + ) } } } From f82712cd67e8859e321cb406cbb3c6d73df4f46f Mon Sep 17 00:00:00 2001 From: kean Date: Fri, 20 Dec 2024 06:20:44 -0500 Subject: [PATCH 2/3] Update release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index d9efb5cf487e..6c88d71b402c 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -35,6 +35,7 @@ * [*] Reader: Enable quick access to notifications on iPad [#23882] * [*] Add support for restricted posts in Reader [#23853] * [*] Fix minor appearance issues in the Blaze campaign list [#23891] +* [*] Fix non-stable order in Posts and Pages section in Stats [#23915] * [*] Improve the sidebar animations and layout on some iPad models [#23886] * [*] Reader: Fix a couple of rare crashes in Reader [#23907] * [*] Reader: Fix an issue with posts shown embedded in the notifications popover on iPad [#23889] From 88e18f51a15787908f546ff15408f190e7512591 Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 9 Jan 2025 12:17:35 -0500 Subject: [PATCH 3/3] Update release notes --- RELEASE-NOTES.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 6c88d71b402c..0d92999a6d5a 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -21,6 +21,7 @@ * [*] Add scroll-to-top button to Reader streams [#23957] * [*] Add a quick way to replace a featured image for a post [#23962] * [*] Fix an issue with posts in Reader sometimes showing incorrect covers [#23914] +* [*] Fix non-stable order in Posts and Pages section in Stats [#23915] 25.6 ----- @@ -35,7 +36,6 @@ * [*] Reader: Enable quick access to notifications on iPad [#23882] * [*] Add support for restricted posts in Reader [#23853] * [*] Fix minor appearance issues in the Blaze campaign list [#23891] -* [*] Fix non-stable order in Posts and Pages section in Stats [#23915] * [*] Improve the sidebar animations and layout on some iPad models [#23886] * [*] Reader: Fix a couple of rare crashes in Reader [#23907] * [*] Reader: Fix an issue with posts shown embedded in the notifications popover on iPad [#23889]