update rowing information to non fricken nanoseconds who though time.Durations should be nanoseconds
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m45s
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 3m45s
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/rwcarlsen/goexif/exif"
|
||||
|
||||
@@ -17,9 +16,9 @@ import (
|
||||
)
|
||||
|
||||
type ExtractedRowingData struct {
|
||||
TimeMinutes float64 `json:"timeMinutes"`
|
||||
TimeSeconds float64 `json:"timeSeconds"`
|
||||
Distance float64 `json:"distance"`
|
||||
TimeMinutes uint64 `json:"timeMinutes"`
|
||||
TimeSeconds uint64 `json:"timeSeconds"`
|
||||
Distance uint64 `json:"distance"`
|
||||
}
|
||||
|
||||
func (store *Store) GetRowing(ctx *gin.Context) {
|
||||
@@ -153,15 +152,16 @@ No text, no markdown, no explanation. Just the JSON object.`),
|
||||
}
|
||||
|
||||
totalSeconds := extractedData.TimeMinutes*60 + extractedData.TimeSeconds
|
||||
totalDuration := time.Duration(totalSeconds * float64(time.Second))
|
||||
per500m := time.Duration(totalSeconds / extractedData.Distance * 500 * float64(time.Second))
|
||||
|
||||
per500m := float64(totalSeconds) / float64(extractedData.Distance) * 500.0
|
||||
calories := float64(extractedData.Distance) / 7500.0 * 500.0
|
||||
|
||||
rowing := models.Rowing{
|
||||
Date: dateTaken,
|
||||
Time: totalDuration,
|
||||
Time: totalSeconds,
|
||||
TimePer500m: per500m,
|
||||
Distance: extractedData.Distance,
|
||||
Calories: extractedData.Distance / 7500.0 * 500.0,
|
||||
Calories: calories,
|
||||
}
|
||||
|
||||
if err := store.DB.Create(&rowing).Error; err != nil {
|
||||
|
||||
@@ -61,8 +61,8 @@ type Rowing struct {
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
|
||||
Date time.Time `json:"date"`
|
||||
Time time.Duration `json:"time"`
|
||||
TimePer500m time.Duration `json:"timePer500m"`
|
||||
Distance float64 `json:"distance"`
|
||||
Time uint64 `json:"time"`
|
||||
Distance uint64 `json:"distance"`
|
||||
TimePer500m float64 `json:"timePer500m"`
|
||||
Calories float64 `json:"calories"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user