Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class InsightsLineChart {
var chartData = [LineChartData]()

let thisWeekDataSet = LineChartDataSet(entries: thisWeekEntries,
label: NSLocalizedString("This Week", comment: "Accessibility label used for distinguishing Views and Visitors in the Stats → Insights Views Visitors Line chart."))
label: NSLocalizedString("stats.insights.accessibility.label.viewsVisitorsLastDays", value: "Last 7-days", comment: "Accessibility label used for distinguishing Views and Visitors in the Stats → Insights Views Visitors Line chart."))
let prevWeekDataSet = LineChartDataSet(entries: prevWeekEntries,
label: NSLocalizedString("Previous Week", comment: "Accessibility label used for distinguishing Views and Visitors in the Stats → Insights Views Visitors Line chart."))
label: NSLocalizedString("stats.insights.accessibility.label.viewsVisitorsPreviousDays", value: "Previous 7-days", comment: "Accessibility label used for distinguishing Views and Visitors in the Stats → Insights Views Visitors Line chart."))
let viewsDataSets = [ thisWeekDataSet, prevWeekDataSet ]
let viewsChartData = LineChartData(dataSets: viewsDataSets)
chartData.append(viewsChartData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,23 @@ class SiteStatsImmuTableRows {
}

enum Constants {
static let viewsHigher = NSLocalizedString("Your views this week are %@ higher than the previous week.\n", comment: "Stats insights views higher than previous week")
static let viewsLower = NSLocalizedString("Your views this week are %@ lower than the previous week.\n", comment: "Stats insights views lower than previous week")
static let visitorsHigher = NSLocalizedString("Your visitors this week are %@ higher than the previous week.\n", comment: "Stats insights visitors higher than previous week")
static let visitorsLower = NSLocalizedString("Your visitors this week are %@ lower than the previous week.\n", comment: "Stats insights visitors lower than previous week")
static let viewsNoDifference = NSLocalizedString("Your views this week are the same as the previous week.\n", comment: "Stats insights label shown when the user's view count is the same as the previous week.")
static let visitorsNoDifference = NSLocalizedString("Your visitors this week are the same as the previous week.\n", comment: "Stats insights label shown when the user's visitor count is the same as the previous week.")
static let viewsHigher = NSLocalizedString("stats.insights.label.views.sevenDays.higher",
value: "Your views in the last 7-days are %@ higher than the previous 7-days.\n",
comment: "Stats insights views higher than previous 7 days")
static let viewsLower = NSLocalizedString("stats.insights.label.views.sevenDays.lower",
value: "Your views in the last 7-days are %@ lower than the previous 7-days.\n",
comment: "Stats insights views lower than previous 7 days")
static let visitorsHigher = NSLocalizedString("stats.insights.label.visitors.sevenDays.higher",
value: "Your visitors in the last 7-days are %@ higher than the previous 7-days.\n",
comment: "Stats insights visitors higher than previous 7 days")
static let visitorsLower = NSLocalizedString("stats.insights.label.visitors.sevenDays.lower",
value: "Your visitors in the last 7-days are %@ lower than the previous 7-days.\n",
comment: "Stats insights visitors lower than previous 7 days")
static let viewsNoDifference = NSLocalizedString("stats.insights.label.views.sevenDays.same",
value: "Your views in the last 7-days are the same as the previous 7-days.\n",
comment: "Stats insights label shown when the user's view count is the same as the previous 7 days.")
static let visitorsNoDifference = NSLocalizedString("stats.insights.label.visitors.sevenDays.same",
value: "Your visitors in the last 7-days are the same as the previous 7-days.\n",
comment: "Stats insights label shown when the user's visitor count is the same as the previous 7 days.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
.insightsTodaysStats,
.insightsPostingActivity,
.insightsTagsAndCategories,
.insightsFollowersWordPress,
.insightsFollowersEmail,
.insightsPublicize]
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ import Foundation
let siteTimeZone = SiteStatsInformation.sharedInstance.siteTimeZone ?? .autoupdatingCurrent
return Date().convert(from: siteTimeZone)
}

class func yesterdayDateForSite() -> Date {
let components = DateComponents(day: -1)
return StatsDataHelper.calendar.date(byAdding: components, to: currentDateForSite()) ?? currentDateForSite()
}
}

fileprivate extension Date {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class InsightsManagementViewController: UITableViewController {
}

private var insightsInactive: [StatSection] {
StatSection.allInsights.filter({ !self.insightsShown.contains($0) })
StatSection.allInsights
.filter({ !self.insightsShown.contains($0) && !InsightsManagementViewController.insightsNotSupportedForManagement.contains($0) })
}

private var hasChanges: Bool {
Expand Down Expand Up @@ -55,8 +56,9 @@ class InsightsManagementViewController: UITableViewController {
self.init(style: FeatureFlag.statsNewAppearance.enabled ? .insetGrouped : .grouped)
self.insightsDelegate = insightsDelegate
self.insightsManagementDelegate = insightsManagementDelegate
self.insightsShown = insightsShown
self.originalInsightsShown = insightsShown
let insightsShownSupportedForManagement = insightsShown.filter { !InsightsManagementViewController.insightsNotSupportedForManagement.contains($0) }
self.insightsShown = insightsShownSupportedForManagement
self.originalInsightsShown = insightsShownSupportedForManagement
}

// MARK: - View
Expand Down Expand Up @@ -388,6 +390,15 @@ private extension InsightsManagementViewController {
action: nil)
}

/// Insight StatSections who share the same insightType are represented by a single card
/// Only display a single one of them for Insight Management
/// insightsCommentsPosts and insightsCommentsAuthors have the same insightType
/// insightsFollowersEmail and insightsFollowersWordpress have the same insightType
private static let insightsNotSupportedForManagement: [StatSection] = [
.insightsFollowersWordPress,
.insightsCommentsAuthors
]

// MARK: - Insights Categories

enum InsightsCategories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class SiteStatsInsightsViewModel: Observable {
self.periodStore = periodStore
let viewsCount = insightsStore.getAllTimeStats()?.viewsCount ?? 0
self.itemToDisplay = pinnedItemStore?.itemToDisplay(for: viewsCount)
self.lastRequestedDate = StatsDataHelper.currentDateForSite()

// Exclude today's data for weekly insights
self.lastRequestedDate = StatsDataHelper.yesterdayDateForSite()
self.lastRequestedPeriod = StatsPeriodUnit.day

insightsChangeReceipt = self.insightsStore.onChange { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ class StatsBaseCell: UITableViewCell {
showDetailsButton.isHidden = false

switch statSection {
case .insightsViewsVisitors, .insightsLikesTotals:
case .insightsViewsVisitors:
showDetailsButton.setTitle(LocalizedText.buttonTitleThisWeek, for: .normal)
case .insightsFollowerTotals, .insightsCommentsTotals:
case .insightsFollowerTotals, .insightsCommentsTotals, .insightsLikesTotals:
showDetailsButton.setTitle(LocalizedText.buttonTitleViewMore, for: .normal)
default:
showDetailsButton.setTitle("", for: .normal)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,14 @@ class StatsTotalInsightsCell: StatsBaseCell {

private enum TextContent {
static let differenceDelimiter = Character("*")
static let differenceHigher = NSLocalizedString("*%@%@ (%@%%)* higher than the previous week", comment: "Label shown on some metrics in the Stats Insights section, such as Comments count. The placeholders will be populated with a change and a percentage – e.g. '+17 (40%) higher than the previous week'. The *s mark the numerical values, which will be highlighted differently from the rest of the text.")
static let differenceLower = NSLocalizedString("*%@%@ (%@%%)* lower than the previous week", comment: "Label shown on some metrics in the Stats Insights section, such as Comments count. The placeholders will be populated with a change and a percentage – e.g. '-17 (40%) lower than the previous week'. The *s mark the numerical values, which will be highlighted differently from the rest of the text.")
static let differenceSame = NSLocalizedString("The same as the previous week", comment: "Label shown in Stats Insights when a metric is showing the same level as the previous week")
static let differenceHigher = NSLocalizedString("stats.insights.label.totalLikes.higher",
value: "*%@%@ (%@%%)* higher than the previous 7-days",
comment: "Label shown on some metrics in the Stats Insights section, such as Comments count. The placeholders will be populated with a change and a percentage – e.g. '+17 (40%) higher than the previous 7-days'. The *s mark the numerical values, which will be highlighted differently from the rest of the text.")
static let differenceLower = NSLocalizedString("stats.insights.label.totalLikes.higher",
value: "*%@%@ (%@%%)* lower than the previous 7-days",
comment: "Label shown on some metrics in the Stats Insights section, such as Comments count. The placeholders will be populated with a change and a percentage – e.g. '-17 (40%) lower than the previous 7-days'. The *s mark the numerical values, which will be highlighted differently from the rest of the text.")
static let differenceSame = NSLocalizedString("stats.insights.label.totalLikes.same",
value: "The same as the previous 7-days",
comment: "Label shown in Stats Insights when a metric is showing the same level as the previous 7 days")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,6 @@ struct StatsSegmentedControlData {
var accessibilityValue: String? {
return segmentDataStub != nil ? "" : "\(segmentData)"
}

enum Constants {
static let viewsHigher = NSLocalizedString("Your views this week are %@ higher than the previous week.\n", comment: "Stats insights views higher than previous week")
static let viewsLower = NSLocalizedString("Your views this week are %@ lower than the previous week.\n", comment: "Stats insights views lower than previous week")
static let visitorsHigher = NSLocalizedString("Your visitors this week are %@ higher than the previous week.\n", comment: "Stats insights visitors higher than previous week")
static let visitorsLower = NSLocalizedString("Your visitors this week are %@ lower than the previous week.\n", comment: "Stats insights visitors lower than previous week")
}
}


Expand Down Expand Up @@ -230,9 +223,9 @@ private extension ViewsVisitorsLineChartCell {
previousData.adjustsFontSizeToFitWidth = true
previousLabel.adjustsFontSizeToFitWidth = true

legendLatestLabel.text = NSLocalizedString("This week", comment: "This week legend label")
legendLatestLabel.text = NSLocalizedString("stats.insights.label.viewsVisitorsLastDays", value: "Last 7-days", comment: "Last 7-days legend label")
legendLatestLabel.adjustsFontSizeToFitWidth = true
legendPreviousLabel.text = NSLocalizedString("Previous week", comment: "Previous week legend label")
legendPreviousLabel.text = NSLocalizedString("stats.insights.label.viewsVisitorsPreviousDays", value: "Previous 7-days", comment: "Previous 7-days legend label")
legendPreviousLabel.adjustsFontSizeToFitWidth = true
}

Expand Down