Skip to content

Commit

Permalink
Add support for opening detail for individual posts in Stats / Authors (
Browse files Browse the repository at this point in the history
  • Loading branch information
kean authored Oct 24, 2024
2 parents 435bcfa + 1f762d8 commit 52bd1f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,25 @@ private extension SiteStatsPeriodViewModel {
func authorsDataRows() -> [StatsTotalRowData] {
let authors = store.getTopAuthors()?.topAuthors.prefix(10) ?? []

return authors.map { StatsTotalRowData(name: $0.name,
data: $0.viewsCount.abbreviatedString(),
dataBarPercent: Float($0.viewsCount) / Float(authors.first!.viewsCount),
userIconURL: $0.iconURL,
showDisclosure: true,
childRows: $0.posts.map { StatsTotalRowData(name: $0.title, data: $0.viewsCount.abbreviatedString()) },
statSection: .periodAuthors)
return authors.map {
StatsTotalRowData(
name: $0.name,
data: $0.viewsCount.abbreviatedString(),
dataBarPercent: Float($0.viewsCount) / Float(authors.first!.viewsCount),
userIconURL: $0.iconURL,
showDisclosure: true,
childRows: $0.posts.map {
StatsTotalRowData(
name: $0.title,
data: $0.viewsCount.abbreviatedString(),
postID: $0.postID,
showDisclosure: true,
disclosureURL: $0.postURL,
statSection: .periodAuthors
)
},
statSection: .periodAuthors
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ private extension StatsTotalRow {

if let disclosureURL = rowData?.disclosureURL {
if let statSection = rowData?.statSection,
statSection == .periodPostsAndPages {
statSection == .periodPostsAndPages || statSection == .periodAuthors {
guard let postID = rowData?.postID else {
DDLogInfo("No postID available to show Post Stats.")
return
Expand Down

0 comments on commit 52bd1f3

Please sign in to comment.