[Stats Refresh] Period Overview card: populate with real data#11485
[Stats Refresh] Period Overview card: populate with real data#11485ScoutHarris merged 2 commits intodevelopfrom
Conversation
|
argh, I completely forgot about this. I took a quick peek to see whether the slowness is my fault, or the actual network taking a long time, using a ages-old tradition of NSLog debugging: diff --git a/WordPressKit/StatsServiceRemoteV2.swift b/WordPressKit/StatsServiceRemoteV2.swift
index e0e9409..da9b486 100644
--- a/WordPressKit/StatsServiceRemoteV2.swift
+++ b/WordPressKit/StatsServiceRemoteV2.swift
@@ -78,6 +78,8 @@ public class StatsServiceRemoteV2: ServiceRemoteWordPressComREST {
return val1
}
+
+ NSLog("dispatched network call for \(period.stringValue) ending on \(endingOn)")
wordPressComRestApi.GET(path, parameters: properties, success: { (response, _) in
guard
let jsonResponse = response as? [String: AnyObject],
@@ -88,6 +90,10 @@ public class StatsServiceRemoteV2: ServiceRemoteWordPressComREST {
return
}
+
+ NSLog("received summary data")
+
+
let periodString = jsonResponse["period"] as? String
let parsedPeriod = periodString.flatMap { StatsPeriodUnit(string: $0) } ?? period
// some responses omit this field! not a reason to fail a whole request parsing though.
@@ -97,10 +103,12 @@ public class StatsServiceRemoteV2: ServiceRemoteWordPressComREST {
period: parsedPeriod,
jsonDictionary: jsonResponse)
else {
+ NSLog("failled mapping, returning nil")
completion(nil, ResponseError.decodingFailure)
return
}
+ NSLog("finished parsing summary")
completion(timestats, nil)
}, failure: { (error, _) in
completion(nil, error)and as I suspected, parsing of this response is rather quick (on the order of magnitude of ~300 ms), but the actual request takes almost a minute (!!!) for getting a year's worth of data — it seems to grow linearly with the amount of views. here are the logs: fetching for day — about a second for a week — 6 seconds month — 20 seconds year: — 50 seconds |
|
Is there a JPOP team we could ping about maybe changing the request here? for what it's worth, the URL we're currently hitting is |
jklausa
left a comment
There was a problem hiding this comment.
works fine, I did some investigation why is this so slow and left some comments about it — hopefully they can be of some use!
|
@jklausa thanks for this additional investigation!
@planarvoid do you all see similar request latency for the longer statistics periods?
Nothing wrong with that! Although it would be great if we could transition |
Fixes #11205
This uses real summary data for the Period Overview card. To note, the chart still uses stub data.
NOTE: As noted on #11342 (comment), fetching summary data can take a really long time, especially with longer Periods. Patience is a virtue.
To test: