Total Distance/Hours Modern UI

greendays2 years ago

Which table holds the data?

greendays2 years ago

I reset the hours to "0". The only issue is the formatting of the total distance in accumulators which is not very pleasing to the eye (with 9 digits after the decimal point).

greendays2 years ago

I drove my car for about 30 minutes or so, and the Hours on the Accumulators changed to 2050. I assume it's in seconds since dividing by 60 is 34 (which is close to the number of minutes I drove).

Anton Tananaev2 years ago

What number are you talking about? What's in the database?

greendays2 years ago

I set "Hours" to 0 and started driving. After about half an hour of driving, this is what I got:

Hours

I belive the number is being reported in seconds, not hours... It's possibly a formatting issue.

I don't know where in the database it is stored. I assume it's in tc_positions, but not sure what query you want me to run to get you the relevant data.

Anton Tananaev2 years ago

You can find the position id in the devices table.

greendays2 years ago

Here is a link to the tc_positions for the device (without latitude,longitude,altitude):

Data

Anton Tananaev2 years ago

And how would I know which device we're talking about?

greendays2 years ago

It's for the device in question (where deviceid=4).

greendays2 years ago

For anyone interested in this topic, I modified modern/src/settings/AccumulatorsPage.js to:

  1. divide item.hours by 1000 * 60 to convert the value to minutes and remove the decimals:
value={(item.hours / (1000 * 60)).toFixed(0)}

and multiply by 1000 * 60 when value is changed:

onChange={(event) => setItem({ ...item, hours: Number(event.target.value) * (1000 * 60) })}

Also, created a new label "positionMinutes; since the resulting value is in minutes:

label={t('positionMinutes')}
  1. reduced the precision of total distance to 2 decimals:
value={distanceFromMeters(item.totalDistance, distanceUnit).toFixed(2)}

I am not a javascript or React programmer. This is what I could come up with. Cheers!