runnerup icon indicating copy to clipboard operation
runnerup copied to clipboard

Wip: Fix HR in DB. Max & avg were swapped

Open Uatschitchun opened this issue 4 years ago • 7 comments

Stumbled upon the fact that max_hr and avg_hr were swapped while looking at the DB's activity

Uatschitchun avatar Oct 05 '21 18:10 Uatschitchun

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

Uatschitchun avatar Oct 06 '21 07:10 Uatschitchun

Oh, there's DBHelper.java where DB updates are done on uprades

Uatschitchun avatar Oct 06 '21 17:10 Uatschitchun

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?!

Uatschitchun avatar Oct 06 '21 17:10 Uatschitchun

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.

gerhardol avatar Oct 06 '21 18:10 gerhardol

This is the DB from my phone: Screenshot_20211007_155402

MaxHR < AvgHR? ;)

Uatschitchun avatar Oct 07 '21 14:10 Uatschitchun

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.

gerhardol avatar Oct 07 '21 17:10 gerhardol

Adding a comment for this in #1072, setting this as a draft. Migration is needed, should be done when other changes are required.

gerhardol avatar Nov 07 '21 19:11 gerhardol

Closing this PR, the TODO is in the code and may be changed at next db update

gerhardol avatar Feb 07 '23 20:02 gerhardol