import Foundation

public struct ProfileStats: Codable, Equatable {
    public static var empty = ProfileStats(songs: 0, likes: 0, followersCount: 0, followingCount: 0, plays: 0)

    public var songs: Int
    public var likes: Int
    public var followersCount: Int
    public var followingCount: Int
    public var plays: Int

    public init(songs: Int, likes: Int, followersCount: Int, followingCount: Int, plays: Int) {
        self.songs = songs
        self.likes = likes
        self.followersCount = followersCount
        self.followingCount = followingCount
        self.plays = plays
    }

    public init(songs: Int, statsDictionary: [String: Int]) {
        self.songs = songs
        self.likes = statsDictionary["upvote_count__sum"] ?? 0
        self.followersCount = statsDictionary["followers_count"] ?? 0
        self.followingCount = statsDictionary["following_count"] ?? 0
        self.plays = statsDictionary["play_count__sum"] ?? 0
    }
}
