Added avg. favs

This commit is contained in:
lumaa-dev 2024-11-02 18:15:52 +01:00
parent f5805b2f4d
commit a6b816a747

View File

@ -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