diff --git a/.air.toml b/.air.toml index 081a9ad2..8405ed01 100644 --- a/.air.toml +++ b/.air.toml @@ -1,13 +1,23 @@ [build] - bin = "./tmp/workout-tracker" - cmd = "make build-server" - delay = 1000 - exclude_dir = ["docs", "testdata", "tmp", "vendor"] - exclude_file = ["assets/output.css", "screenshots.js"] - exclude_regex = ["_templ.go", "_test.go"] + bin = "./tmp/workout-tracker" + cmd = "make build-server" + delay = 1000 + exclude_dir = ["docs", "testdata", "tmp", "vendor"] + exclude_file = ["assets/output.css", "screenshots.js"] + exclude_regex = ["_templ.go", "_test.go"] exclude_unchanged = false - include_ext = ["css", "go", "html", "js", "json", "templ", "tmpl", "tpl"] - stop_on_error = true + include_ext = [ + "css", + "go", + "html", + "js", + "json", + "templ", + "tmpl", + "tpl", + "yaml", + ] + stop_on_error = true [screen] clear_on_rebuild = false diff --git a/pkg/database/statistics.go b/pkg/database/statistics.go index 3739abcc..d9c9ce0d 100644 --- a/pkg/database/statistics.go +++ b/pkg/database/statistics.go @@ -88,7 +88,7 @@ func (u *User) GetStatistics(statConfig StatConfig) (*Statistics, error) { Buckets: map[WorkoutType]Buckets{}, } - rows, err := u.db. + q := u.db. Table("workouts"). Select( "count(*) as workouts", @@ -102,9 +102,13 @@ func (u *User) GetStatistics(statConfig StatConfig) (*Statistics, error) { statConfig.GetBucketFormatExpression(sqlDialect), ). Joins("join map_data on workouts.id = map_data.workout_id"). - Where("user_id = ?", u.ID). - Where(GetDateLimitExpression(sqlDialect), "-"+statConfig.GetSince()). - Group("bucket, workout_type").Rows() + Where("user_id = ?", u.ID) + + if statConfig.Since != "" && statConfig.Since != "forever" { + q = q.Where(GetDateLimitExpression(sqlDialect), "-"+statConfig.GetSince()) + } + + rows, err := q.Group("bucket, workout_type").Rows() if err != nil { return nil, err } diff --git a/translations/en.yaml b/translations/en.yaml index d3576cc1..f9e1798d 100644 --- a/translations/en.yaml +++ b/translations/en.yaml @@ -1,8 +1,8 @@ --- en: + forever: forever Heatmap: Heatmap "(Re)generate publicly shareable link": "(Re)generate publicly shareable link" - 1 day: 1 day 1 month: 1 month 1 year: 1 year 10 years: 10 years diff --git a/views/helpers/statistics.go b/views/helpers/statistics.go index 1c4de8fa..d009086b 100644 --- a/views/helpers/statistics.go +++ b/views/helpers/statistics.go @@ -2,10 +2,10 @@ package helpers func StatisticSinceOptions() []string { return []string{ - "1 day", "7 days", "1 month", "3 months", "6 months", "1 year", "2 years", "5 years", "10 years", + "forever", } }