Skip to content

Commit b1cc045

Browse files
author
Clément Le Provost
authored
Support percentileComputation search parameter (#365)
1 parent bd2e2ad commit b1cc045

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

Source/Query.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,17 @@ open class Query : AbstractQuery {
767767
set { self["maxFacetHits"] = Query.buildUInt(newValue) }
768768
}
769769

770+
/// Whether to include the query in processing time percentile computation.
771+
///
772+
/// When true, the API records the processing time of the search query and includes it when computing the 90% and
773+
/// 99% percentiles, available in your Algolia dashboard. When `false`, the search query is excluded from
774+
/// percentile computation.
775+
///
776+
public var percentileComputation: Bool? {
777+
get { return Query.parseBool(self["percentileComputation"]) }
778+
set { self["percentileComputation"] = Query.buildBool(newValue) }
779+
}
780+
770781
// MARK: - Initialization
771782

772783
/// Construct a query with the specified full text query.
@@ -1044,4 +1055,10 @@ open class Query : AbstractQuery {
10441055
get { return AbstractQuery.toNumber(self.maxFacetHits) }
10451056
set { self.maxFacetHits = newValue?.uintValue }
10461057
}
1058+
1059+
@objc(percentileComputation)
1060+
public var z_objc_percentileComputation: NSNumber? {
1061+
get { return AbstractQuery.toNumber(self.percentileComputation) }
1062+
set { self.percentileComputation = newValue?.boolValue }
1063+
}
10471064
}

Tests/ObjectiveCBridging.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,17 @@ - (void)test_minimumAroundRadius {
599599
XCTAssertEqualObjects(query2.minimumAroundRadius, value);
600600
}
601601

602+
- (void)test_percentileComputation {
603+
Query* query1 = [Query new];
604+
XCTAssertNil(query1.percentileComputation);
605+
606+
NSNumber* value = [NSNumber numberWithBool:FALSE];
607+
query1.percentileComputation = value;
608+
XCTAssertEqualObjects(query1[@"percentileComputation"], @"false");
609+
Query* query2 = [Query parse:[query1 build]];
610+
XCTAssertEqualObjects(query2.percentileComputation, value);
611+
}
612+
602613
// MARK: Places
603614

604615
- (void)testPlacesClient {

Tests/QueryTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,4 +770,14 @@ class QueryTests: XCTestCase {
770770
let query2 = Query.parse(query1.build())
771771
XCTAssertEqual(query2.maxFacetHits, query1.maxFacetHits)
772772
}
773+
774+
func test_percentileComputation() {
775+
let query1 = Query()
776+
XCTAssertNil(query1.percentileComputation)
777+
query1.percentileComputation = false
778+
XCTAssertEqual(query1.percentileComputation, false)
779+
XCTAssertEqual(query1["percentileComputation"], "false")
780+
let query2 = Query.parse(query1.build())
781+
XCTAssertEqual(query2.percentileComputation, false)
782+
}
773783
}

0 commit comments

Comments
 (0)