diff --git a/Bubble/Data/Metrics/MetricsManager.swift b/Bubble/Data/Metrics/MetricsManager.swift index 09d31e2..b5e0ac4 100644 --- a/Bubble/Data/Metrics/MetricsManager.swift +++ b/Bubble/Data/Metrics/MetricsManager.swift @@ -11,6 +11,7 @@ final class MetricsManager { private(set) public var postCount: [IntData] = [] private(set) public var postType: [StatusTypeData] = [] + private(set) public var averageFavorites: Int = 0 init(accountManager: AccountManager) { if let cli = accountManager.getClient() { @@ -51,6 +52,17 @@ final class MetricsManager { } } + private func averageFavorites(_ statuses: [Status]) -> Int { + let favsCount: [Int] = statuses.map { $0.favouritesCount } + + var totalFavs: Int = 0 + favsCount.forEach { int in + totalFavs += int + } + + return totalFavs / favsCount.count + } + /// Data used for integer Metrics struct IntData: GraphData { let date: Date