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"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/rwcarlsen/goexif/exif"
|
"github.com/rwcarlsen/goexif/exif"
|
||||||
|
|
||||||
@@ -17,9 +16,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ExtractedRowingData struct {
|
type ExtractedRowingData struct {
|
||||||
TimeMinutes float64 `json:"timeMinutes"`
|
TimeMinutes uint64 `json:"timeMinutes"`
|
||||||
TimeSeconds float64 `json:"timeSeconds"`
|
TimeSeconds uint64 `json:"timeSeconds"`
|
||||||
Distance float64 `json:"distance"`
|
Distance uint64 `json:"distance"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) GetRowing(ctx *gin.Context) {
|
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
|
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{
|
rowing := models.Rowing{
|
||||||
Date: dateTaken,
|
Date: dateTaken,
|
||||||
Time: totalDuration,
|
Time: totalSeconds,
|
||||||
TimePer500m: per500m,
|
TimePer500m: per500m,
|
||||||
Distance: extractedData.Distance,
|
Distance: extractedData.Distance,
|
||||||
Calories: extractedData.Distance / 7500.0 * 500.0,
|
Calories: calories,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := store.DB.Create(&rowing).Error; err != nil {
|
if err := store.DB.Create(&rowing).Error; err != nil {
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ type Rowing struct {
|
|||||||
CreatedAt time.Time `json:"createdAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt"`
|
||||||
Date time.Time `json:"date"`
|
Date time.Time `json:"date"`
|
||||||
Time time.Duration `json:"time"`
|
Time uint64 `json:"time"`
|
||||||
TimePer500m time.Duration `json:"timePer500m"`
|
Distance uint64 `json:"distance"`
|
||||||
Distance float64 `json:"distance"`
|
TimePer500m float64 `json:"timePer500m"`
|
||||||
Calories float64 `json:"calories"`
|
Calories float64 `json:"calories"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user