Add options to choose type of bike, and also persist distance, power, calories, speed to db

This commit is contained in:
Peter Stockings
2023-03-14 10:19:37 +11:00
parent f1c89e967a
commit faf9b82137
5 changed files with 141 additions and 38 deletions

View File

@@ -23,7 +23,7 @@
</svg>
<div>
{{ user.name }}
{{ user.name }} - {{ user.bike.display_name }}
</div>
</div>
</a>
@@ -324,8 +324,8 @@
// Add the new data point to the data array
data.push(newData);
let watts = generators.aab.rpm.power(rpm)
let speed = generators.aab.rpm.speed(rpm)
let watts = generators['{{ user.bike.code_name }}'].rpm.power(rpm)
let speed = generators['{{ user.bike.code_name }}'].rpm.speed(rpm)
if (previousReadingTime) {
distance += calculateDistance(previousReadingTime, new Date(), speed)
calories += calculateCalories(previousReadingTime, new Date(), watts)