Open MtnBiker opened 3 years ago
Hi @MtnBiker
Thanks for the feedback. Reopening this issue because I plan to add the heart rate as you suggested.
Great. I would also suggest you put systolic firsts since that's standard.
I've got my version working. But because the time stamp for hr is later, I used a crude hack to pick it up. Crude because time becomes a string and it's hard to do math on a string. Which just gave me an idea. Does Ruby have .to_t? Of course not, but parsing the string and doing the math is straightforward.
You can parse a String and make it a Date object with DateTime.parse
Feel free to create a separate issue for the Suggested change in order;)
I'm working on how to use the script in my Rails app. But I need to understand a couple of concepts better. If/when I succeed, I'll get back.
Edit: Not as simple as stated. HR is not exactly at same time. But maybe I can still sort it out. Edit 2: My data has too many differences, so will work on another version. Withings records heart rate two different ways. One as shown below and HKQuantityTypeIdentifierHeartRate. And the time stamp is exactly the same; occurs some seconds later.
This works great. Withings BPM Connect also records heart rate with the same time stamp. I may be able to figure it out but realized you've assumed only time, systolic and diastolic. Simple hacking appears easy except for the
def call(diastolic_records, systolic_records, hr_records)
method.XPATH_HEARTRATE= "//Record[contains(@type,'HKQuantityTypeIdentifierRestingHeartRate')]"
If I figure it out I'll let you know. Your Ruby skills are way beyond mine. I want to include something like this in a Rails app to better view the data.
Thank you for putting this together. I was able to hack it even though I don't understand all of what you've done.