Skip to content

Storage: Add siteID parameter to stats queries #8445

Open
@ealeksandrov

Description

@ealeksandrov

Description

Due to missing siteID parameter in StorageType+Extensions for stats related objects, we are ignoring multi-store support and overwriting data between stores.

It doesn't result in any user-facing errors, since we're overwriting siteID as well, so it's just unnecessary removal of the data from unrelated store.

// MARK: - Stats
/// Retrieves the Stored TopEarnerStats.
///
func loadTopEarnerStats(date: String, granularity: String) -> TopEarnerStats? {
let predicate = \TopEarnerStats.date =~ date && \TopEarnerStats.granularity =~ granularity
return firstObject(ofType: TopEarnerStats.self, matching: predicate)
}
/// Retrieves the Stored SiteVisitStats for stats v4.
///
func loadSiteVisitStats(granularity: String, timeRange: String) -> SiteVisitStats? {
let predicate = \SiteVisitStats.granularity =~ granularity && \SiteVisitStats.timeRange == timeRange
return firstObject(ofType: SiteVisitStats.self, matching: predicate)
}
/// Retrieves the Stored OrderStats for V4 API.
///
func loadOrderStatsV4(siteID: Int64, timeRange: String) -> OrderStatsV4? {
let predicate = \OrderStatsV4.siteID == siteID && \OrderStatsV4.timeRange =~ timeRange
return firstObject(ofType: OrderStatsV4.self, matching: predicate)
}
/// Retrieves the Stored OrderStatsV4interval.
///
func loadOrderStatsInterval(interval: String, orderStats: OrderStatsV4) -> OrderStatsV4Interval? {
let predicate = \OrderStatsV4Interval.interval =~ interval && \OrderStatsV4Interval.stats == orderStats
return firstObject(ofType: OrderStatsV4Interval.self, matching: predicate)
}
/// Retrieves the Stored SiteSummaryStats.
///
func loadSiteSummaryStats(date: String, period: String) -> SiteSummaryStats? {
let predicate = \SiteSummaryStats.date =~ date && \SiteSummaryStats.period =~ period
return firstObject(ofType: SiteSummaryStats.self, matching: predicate)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature: statsRelated to stats, including Top Performers.type: enhancementA request for an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions