From 646f93136dd62e699ba8358a7695fadab9d579a6 Mon Sep 17 00:00:00 2001 From: Adam French Date: Wed, 4 Mar 2026 16:48:21 +0000 Subject: [PATCH] update rowing information to non fricken nanoseconds who though time.Durations should be nanoseconds --- backend/handlers/handle_rowing.go | 16 ++++++++-------- backend/models/models.go | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/handlers/handle_rowing.go b/backend/handlers/handle_rowing.go index 448a86f..568212a 100644 --- a/backend/handlers/handle_rowing.go +++ b/backend/handlers/handle_rowing.go @@ -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 { diff --git a/backend/models/models.go b/backend/models/models.go index f6b47b3..7a6ddb1 100644 --- a/backend/models/models.go +++ b/backend/models/models.go @@ -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"` }