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 postCount: [IntData] = []
|
||||||
private(set) public var postType: [StatusTypeData] = []
|
private(set) public var postType: [StatusTypeData] = []
|
||||||
|
private(set) public var averageFavorites: Int = 0
|
||||||
|
|
||||||
init(accountManager: AccountManager) {
|
init(accountManager: AccountManager) {
|
||||||
if let cli = accountManager.getClient() {
|
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
|
/// Data used for integer Metrics
|
||||||
struct IntData: GraphData {
|
struct IntData: GraphData {
|
||||||
let date: Date
|
let date: Date
|
||||||
|
|
Loading…
Reference in New Issue