mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2024-12-26 16:55:15 +01:00
Added avg. favs
This commit is contained in:
parent
f5805b2f4d
commit
a6b816a747
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user