Skip to content

Commit 52bd1f3

Browse files
authored
Add support for opening detail for individual posts in Stats / Authors (#23689)
2 parents 435bcfa + 1f762d8 commit 52bd1f3

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

WordPress/Classes/ViewRelated/Stats/Period Stats/SiteStatsPeriodViewModel.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -567,13 +567,25 @@ private extension SiteStatsPeriodViewModel {
567567
func authorsDataRows() -> [StatsTotalRowData] {
568568
let authors = store.getTopAuthors()?.topAuthors.prefix(10) ?? []
569569

570-
return authors.map { StatsTotalRowData(name: $0.name,
571-
data: $0.viewsCount.abbreviatedString(),
572-
dataBarPercent: Float($0.viewsCount) / Float(authors.first!.viewsCount),
573-
userIconURL: $0.iconURL,
574-
showDisclosure: true,
575-
childRows: $0.posts.map { StatsTotalRowData(name: $0.title, data: $0.viewsCount.abbreviatedString()) },
576-
statSection: .periodAuthors)
570+
return authors.map {
571+
StatsTotalRowData(
572+
name: $0.name,
573+
data: $0.viewsCount.abbreviatedString(),
574+
dataBarPercent: Float($0.viewsCount) / Float(authors.first!.viewsCount),
575+
userIconURL: $0.iconURL,
576+
showDisclosure: true,
577+
childRows: $0.posts.map {
578+
StatsTotalRowData(
579+
name: $0.title,
580+
data: $0.viewsCount.abbreviatedString(),
581+
postID: $0.postID,
582+
showDisclosure: true,
583+
disclosureURL: $0.postURL,
584+
statSection: .periodAuthors
585+
)
586+
},
587+
statSection: .periodAuthors
588+
)
577589
}
578590
}
579591

WordPress/Classes/ViewRelated/Stats/Shared Views/StatsTotalRow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ private extension StatsTotalRow {
446446

447447
if let disclosureURL = rowData?.disclosureURL {
448448
if let statSection = rowData?.statSection,
449-
statSection == .periodPostsAndPages {
449+
statSection == .periodPostsAndPages || statSection == .periodAuthors {
450450
guard let postID = rowData?.postID else {
451451
DDLogInfo("No postID available to show Post Stats.")
452452
return

0 commit comments

Comments
 (0)