Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request - Option to filter manually entered data #47

Open
antoinedelp opened this issue Mar 18, 2020 · 4 comments
Open

Feature request - Option to filter manually entered data #47

antoinedelp opened this issue Mar 18, 2020 · 4 comments

Comments

@antoinedelp
Copy link

Hi and thanks for this neat package!

I'm submitting a feature request for the possibility to left out user entered data when querying for distance/steps. This would enable to use only "real" data.

As a test, I managed to implement it in the iOs version of GetSteps by doing the following:

  • Declare a predicate that leaves out User Entered data

NSPredicate *sourcePredicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];

  • Use this predicate when querying:

HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:type quantitySamplePredicate:nil options:HKStatisticsOptionCumulativeSum anchorDate:anchorDate intervalComponents:interval];

I'd like to work on that feature request, but I do not master Swift nor Java and haven't experienced working on a bridge between RN and Native. I'm more than happy to help you, let me know how I could proceed!

Cheers

@pvlvukovic
Copy link

Any news on this?
Would be great to filter manually entered data!

@pvlvukovic
Copy link

Hi and thanks for this neat package!

I'm submitting a feature request for the possibility to left out user entered data when querying for distance/steps. This would enable to use only "real" data.

As a test, I managed to implement it in the iOs version of GetSteps by doing the following:

  • Declare a predicate that leaves out User Entered data

NSPredicate *sourcePredicate = [NSPredicate predicateWithFormat:@"metadata.%K != YES", HKMetadataKeyWasUserEntered];

  • Use this predicate when querying:

HKStatisticsCollectionQuery *query = [[HKStatisticsCollectionQuery alloc] initWithQuantityType:type quantitySamplePredicate:nil options:HKStatisticsOptionCumulativeSum anchorDate:anchorDate intervalComponents:interval];

I'd like to work on that feature request, but I do not master Swift nor Java and haven't experienced working on a bridge between RN and Native. I'm more than happy to help you, let me know how I could proceed!

Cheers

this seems to work, still needs testing.

Perhaps there is a solution for android also
In Manager.java there are processSteps and processDistances methods

            if (!"user_input".equals(dp.getOriginalDataSource().getStreamName())) {
                caloryMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
                caloryMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
                caloryMap.putDouble("quantity", dp.getValue(field).asFloat());
                map.pushMap(caloryMap);
            }
            
            This if might solve it

@IsaacInsoll
Copy link

Hi,
It seems like someone has already made a fork that does the 'exclude user entered data' on both the android and iOS side:
https://github.com/LVGP2021/react-native-fitness

It seems like this should be exposed as an option when querying (IE: either 'get all steps' or 'get not-manually-entered-steps) rather than it being 'hard ignored' all the time.

Is this project still active? If so I might refactor that code to make it an option and then do an MR in :)

@Francesco-Voto
Copy link
Contributor

Hi @IsaacInsoll ,
thanks foor your reply. Feel free to open a PR, any help will be appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants