Skip to content

Commit 71576b4

Browse files
committed
Add action
1 parent a3c0df6 commit 71576b4

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Yosemite/Yosemite/Actions/StatsActionV4.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ public enum StatsActionV4: Action {
1919
forceRefresh: Bool,
2020
onCompletion: (Result<Void, Error>) -> Void)
2121

22+
/// Retrieves `OrderStats` for the provided siteID, and time range, without saving them to the Storage layer.
23+
///
24+
case retrieveCustomStats(siteID: Int64,
25+
unit: StatsGranularityV4,
26+
earliestDateToInclude: Date,
27+
latestDateToInclude: Date,
28+
quantity: Int,
29+
forceRefresh: Bool,
30+
onCompletion: (Result<OrderStatsV4, Error>) -> Void)
31+
2232
/// Synchronizes `SiteVisitStats` for the provided siteID, time range, and date.
2333
///
2434
case retrieveSiteVisitStats(siteID: Int64,

Yosemite/Yosemite/Stores/StatsStoreV4.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ public final class StatsStoreV4: Store {
5050
quantity: quantity,
5151
forceRefresh: forceRefresh,
5252
onCompletion: onCompletion)
53+
case .retrieveCustomStats(let siteID,
54+
let unit,
55+
let earliestDateToInclude,
56+
let latestDateToInclude,
57+
let quantity,
58+
let forceRefresh,
59+
let onCompletion):
60+
retrieveCustomStats(siteID: siteID,
61+
unit: unit,
62+
earliestDateToInclude: earliestDateToInclude,
63+
latestDateToInclude: latestDateToInclude,
64+
quantity: quantity,
65+
forceRefresh: forceRefresh,
66+
onCompletion: onCompletion)
5367
case .retrieveSiteVisitStats(let siteID,
5468
let siteTimezone,
5569
let timeRange,
@@ -120,6 +134,24 @@ private extension StatsStoreV4 {
120134
}
121135
}
122136

137+
/// Retrieves the order stats for the provided siteID, and time range, without saving them to the Storage layer.
138+
///
139+
func retrieveCustomStats(siteID: Int64,
140+
unit: StatsGranularityV4,
141+
earliestDateToInclude: Date,
142+
latestDateToInclude: Date,
143+
quantity: Int,
144+
forceRefresh: Bool,
145+
onCompletion: @escaping (Result<OrderStatsV4, Error>) -> Void) {
146+
orderStatsRemote.loadOrderStats(for: siteID,
147+
unit: unit,
148+
earliestDateToInclude: earliestDateToInclude,
149+
latestDateToInclude: latestDateToInclude,
150+
quantity: quantity,
151+
forceRefresh: forceRefresh,
152+
completion: onCompletion)
153+
}
154+
123155
/// Retrieves the site visit stats associated with the provided Site ID (if any!).
124156
///
125157
func retrieveSiteVisitStats(siteID: Int64,

0 commit comments

Comments
 (0)