Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 27c080f

Browse files
committed
Insights Today: don't fail parsing, just populate with zeros if necessary.
1 parent 269029d commit 27c080f

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

WordPressKit/Insights/StatsTodayInsight.swift

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,9 @@ extension StatsTodayInsight: StatsInsightData {
2323
}
2424

2525
public init?(jsonDictionary: [String: AnyObject]) {
26-
guard
27-
let viewsCount = jsonDictionary["views"] as? Int,
28-
let visitorsCount = jsonDictionary["visitors"] as? Int,
29-
let likesCount = jsonDictionary["likes"] as? Int,
30-
let commentsCount = jsonDictionary["comments"] as? Int
31-
else {
32-
return nil
33-
}
34-
35-
self.visitorsCount = visitorsCount
36-
self.viewsCount = viewsCount
37-
self.likesCount = likesCount
38-
self.commentsCount = commentsCount
26+
self.visitorsCount = jsonDictionary["visitors"] as? Int ?? 0
27+
self.viewsCount = jsonDictionary["views"] as? Int ?? 0
28+
self.likesCount = jsonDictionary["likes"] as? Int ?? 0
29+
self.commentsCount = jsonDictionary["comments"] as? Int ?? 0
3930
}
4031
}

0 commit comments

Comments
 (0)