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

Commit 95d6ab5

Browse files
authored
Merge pull request #159 from wordpress-mobile/bug/allow-specifying-limit-for-summary-queries
Fix bug that prevented the `limit` parameter being respected by the `StatsSummaryTimeIntervalData` fetches
2 parents 05a4a52 + 63e0ad2 commit 95d6ab5

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

WordPressKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "WordPressKit"
3-
s.version = "4.1.1"
3+
s.version = "4.1.2-beta.1"
44
s.summary = "WordPressKit offers a clean and simple WordPress.com and WordPress.org API."
55

66
s.description = <<-DESC

WordPressKit/StatsServiceRemoteV2.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,9 @@ public class StatsServiceRemoteV2: ServiceRemoteWordPressComREST {
6969
let path = self.path(forEndpoint: "sites/\(siteID)/\(pathComponent)/", withVersion: ._1_1)
7070

7171
let staticProperties = ["period": period.stringValue,
72-
"date": periodDataQueryDateFormatter.string(from: endingOn),
73-
"max": limit as AnyObject] as [String: AnyObject]
72+
"date": periodDataQueryDateFormatter.string(from: endingOn)] as [String: AnyObject]
7473

75-
let classProperties = TimeStatsType.queryProperties(with: endingOn, period: period) as [String: AnyObject]
74+
let classProperties = TimeStatsType.queryProperties(with: endingOn, period: period, maxCount: limit) as [String: AnyObject]
7675

7776
let properties = staticProperties.merging(classProperties) { val1, _ in
7877
return val1
@@ -263,13 +262,13 @@ public protocol StatsTimeIntervalData {
263262

264263
init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String: AnyObject])
265264

266-
static func queryProperties(with date: Date, period: StatsPeriodUnit) -> [String: String]
265+
static func queryProperties(with date: Date, period: StatsPeriodUnit, maxCount: Int) -> [String: String]
267266
}
268267

269268
extension StatsTimeIntervalData {
270269

271-
public static func queryProperties(with date: Date, period: StatsPeriodUnit) -> [String: String] {
272-
return [:]
270+
public static func queryProperties(with date: Date, period: StatsPeriodUnit, maxCount: Int) -> [String: String] {
271+
return ["max": String(maxCount)]
273272
}
274273

275274
// Most of the responses for time data come in a unwieldy format, that requires awkwkard unwrapping

WordPressKit/Time Interval/StatsSummaryTimeIntervalData.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ extension StatsSummaryTimeIntervalData: StatsTimeIntervalData {
4242
return "stats/visits"
4343
}
4444

45-
public static func queryProperties(with date: Date, period: StatsPeriodUnit) -> [String: String] {
46-
return ["quantity": "10",
47-
"stat_fields": "views,visitors,likes,comments",
48-
"unit": period.stringValue]
45+
public static func queryProperties(with date: Date, period: StatsPeriodUnit, maxCount: Int) -> [String : String] {
46+
return ["unit": period.stringValue,
47+
"quantity": String(maxCount)]
4948
}
5049

5150
public init?(date: Date, period: StatsPeriodUnit, jsonDictionary: [String : AnyObject]) {

0 commit comments

Comments
 (0)