Wip: Fix HR in DB. Max & avg were swapped
Stumbled upon the fact that max_hr and avg_hr were swapped while looking at the DB's activity
Max & avg HR are swamped in DB. My test recording yesterday to test cadence resulted in 183 avg HR & 152 max HR for that activity.
Yes, for to fix existing workouts this would need a migration in DB. But should RU still record swapped measures into DB?
I fear that every export (#1054) uses those swapped values...
I see 3 possibilities: 1.) just swap and record new workouts correctly from now on, leaving the existing workouts in a false state
2.) swap for new workouts to be recorded correctly and do a DB migration initiated in the "what's new" update thread.
- if I see correctly, there's no DB scheme version in the DB. So no way to update to a new scheme version or testing for version numbers. One could check against build versions though...
UPDATE activity
SET max_hr = avg_hr,
avg_hr = max_hr
will do
3.) Leave it as it is and record false values further on
Oh, there's DBHelper.java where DB updates are done on uprades
I've even noticed, that MAX_HR isn't written (nor calculated) for DB.LAP.MAX_HR. Value should possibly written in Step.java onStop(). But where to calculate from? Could, afaics, be only calculated from DB.LOCATION.HR in scope.LAP?!
I did not see any swapped uses, the constant names (actual names of the database columns) could well be xxxx and yyyy. So how can you get other values?
If possible avoid database upgrades, it makes it much harder to downgrade. Especially when developing.
This is the DB from my phone:

MaxHR < AvgHR? ;)
This is the DB from my phone:
The SW uses MAX_HR="avg_hr" in all accesses, it does not matter what the actual db column is called.
I still suggest to just add a comment.
Adding a comment for this in #1072, setting this as a draft. Migration is needed, should be done when other changes are required.
Closing this PR, the TODO is in the code and may be changed at next db update