@@ -67,20 +67,6 @@ public struct StatsTopCommentsPost: Codable {
6767}
6868
6969private extension StatsTopCommentsAuthor {
70- public init ( from decoder: Decoder ) throws {
71- let container = try decoder. container ( keyedBy: CodingKeys . self)
72- let name = try container. decode ( String . self, forKey: . name)
73- let commentCount : Int
74- if let comments = try ? container. decodeIfPresent ( String . self, forKey: . commentCount) {
75- commentCount = Int ( comments) ?? 0
76- } else {
77- commentCount = 0
78- }
79- let iconURL = try container. decodeIfPresent ( String . self, forKey: . iconURL)
80-
81- self . init ( name: name, avatar: iconURL, commentCount: commentCount)
82- }
83-
8470 init ( name: String , avatar: String ? , commentCount: Int ) {
8571 let url : URL ?
8672
@@ -97,8 +83,24 @@ private extension StatsTopCommentsAuthor {
9783 }
9884}
9985
100- private extension StatsTopCommentsPost {
101- public init ( from decoder: Decoder ) throws {
86+ public extension StatsTopCommentsAuthor {
87+ init ( from decoder: Decoder ) throws {
88+ let container = try decoder. container ( keyedBy: CodingKeys . self)
89+ let name = try container. decode ( String . self, forKey: . name)
90+ let commentCount : Int
91+ if let comments = try ? container. decodeIfPresent ( String . self, forKey: . commentCount) {
92+ commentCount = Int ( comments) ?? 0
93+ } else {
94+ commentCount = 0
95+ }
96+ let iconURL = try container. decodeIfPresent ( String . self, forKey: . iconURL)
97+
98+ self . init ( name: name, avatar: iconURL, commentCount: commentCount)
99+ }
100+ }
101+
102+ public extension StatsTopCommentsPost {
103+ init ( from decoder: Decoder ) throws {
102104 let container = try decoder. container ( keyedBy: CodingKeys . self)
103105 let name = try container. decode ( String . self, forKey: . name)
104106 let postID = try container. decode ( String . self, forKey: . postID)
0 commit comments