Commit 67679c39 authored by Furyou81's avatar Furyou81

adding a flag includeManuallyAdded

parent ad2e4eac
......@@ -104,6 +104,8 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
......@@ -118,6 +120,7 @@
endDate:endDate
ascending:ascending
limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
......@@ -221,6 +224,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
......@@ -235,6 +239,7 @@
endDate:endDate
ascending:ascending
limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
......@@ -253,6 +258,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
......@@ -267,6 +273,7 @@
endDate:endDate
ascending:ascending
limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
......@@ -309,6 +316,7 @@
NSDate *startDate = [RCTAppleHealthKit dateFromOptions:input key:@"startDate" withDefault:nil];
NSDate *endDate = [RCTAppleHealthKit dateFromOptions:input key:@"endDate" withDefault:[NSDate date]];
NSUInteger period = [RCTAppleHealthKit uintFromOptions:input key:@"period" withDefault:60];
BOOL includeManuallyAdded = [RCTAppleHealthKit boolFromOptions:input key:@"includeManuallyAdded" withDefault:false];
if(startDate == nil){
callback(@[RCTMakeError(@"startDate is required in options", nil, nil)]);
return;
......@@ -323,6 +331,7 @@
endDate:endDate
ascending:ascending
limit:limit
includeManuallyAdded:includeManuallyAdded
completion:^(NSArray *arr, NSError *err){
if (err != nil) {
NSLog(@"error with fetchCumulativeSumStatisticsCollection: %@", err);
......
......@@ -57,6 +57,7 @@
endDate:(NSDate *)endDate
ascending:(BOOL)asc
limit:(NSUInteger)lim
includeManuallyAdded:(BOOL)includeManuallyAdded
completion:(void (^)(NSArray *, NSError *))completionHandler;
......
......@@ -578,6 +578,7 @@
endDate:(NSDate *)endDate
ascending:(BOOL)asc
limit:(NSUInteger)lim
includeManuallyAdded:(BOOL)includeManuallyAdded
completion:(void (^)(NSArray *, NSError *))completionHandler {
NSCalendar *calendar = [NSCalendar currentCalendar];
......@@ -588,7 +589,10 @@
fromDate:startDate];
//anchorComponents.hour = 0;
NSDate *anchorDate = [calendar dateFromComponents:anchorComponents];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
NSPredicate *predicate = nil;
if (includeManuallyAdded == false) {
predicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];
}
// Create the query
HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:quantityType
quantitySamplePredicate:predicate
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment