Skip to content

Commit

Permalink
Merge pull request #405 from jovandeginste/add-debug-cmd
Browse files Browse the repository at this point in the history
Add a debugger tool
  • Loading branch information
jovandeginste authored Jan 19, 2025
2 parents 7d685b4 + 7ce2c09 commit 940dbea
Show file tree
Hide file tree
Showing 114 changed files with 29,902 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
multi_binaries: true
project_path: ./cmd/...
ldflags: |
-X "main.buildTime=${{ env.BUILD_TIME }}"
-X main.gitCommit=${{ github.sha }}
Expand Down
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ GIT_REF_NAME ?= $(shell git branch --show-current)
GIT_REF_TYPE ?= branch
GIT_COMMIT ?= $(shell git rev-parse HEAD)
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
OUTPUT_FILE ?= tmp/workout-tracker
WT_OUTPUT_FILE ?= tmp/workout-tracker
WT_DEBUG_OUTPUT_FILE ?= tmp/wt-debug

THEME_SCREENSHOT_WIDTH ?= 1200
THEME_SCREENSHOT_HEIGHT ?= 900
Expand All @@ -30,10 +31,15 @@ dev:
build: build-dist build-server build-docker screenshots
meta: swagger screenshots changelog

build-cli: build-tw build-templates
go build \
-ldflags "-X 'main.buildTime=$(BUILD_TIME)' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.gitRef=$(GIT_REF)' -X 'main.gitRefName=$(GIT_REF_NAME)' -X 'main.gitRefType=$(GIT_REF_TYPE)'" \
-o $(WT_DEBUG_OUTPUT_FILE) ./cmd/wt-debug/

build-server: build-tw build-templates
go build \
-ldflags "-X 'main.buildTime=$(BUILD_TIME)' -X 'main.gitCommit=$(GIT_COMMIT)' -X 'main.gitRef=$(GIT_REF)' -X 'main.gitRefName=$(GIT_REF_NAME)' -X 'main.gitRefType=$(GIT_REF_TYPE)'" \
-o $(OUTPUT_FILE) ./cmd/workout-tracker/
-o $(WT_OUTPUT_FILE) ./cmd/workout-tracker/

build-docker:
docker build -t workout-tracker --pull \
Expand Down Expand Up @@ -88,7 +94,7 @@ format-templates:
find . -type f -name '*.templ' -exec templ fmt -v {} \;

serve:
$(OUTPUT_FILE)
$(WT_OUTPUT_FILE)

test: test-go test-assets test-templates

Expand Down
43 changes: 43 additions & 0 deletions cmd/wt-debug/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
appassets "github.com/jovandeginste/workout-tracker/v2/assets"
"github.com/jovandeginste/workout-tracker/v2/pkg/app"
"github.com/jovandeginste/workout-tracker/v2/pkg/version"
apptranslations "github.com/jovandeginste/workout-tracker/v2/translations"
"gorm.io/gorm"
)

type cli struct {
app *app.App
}

func newCLI() (*cli, error) {
a := app.NewApp(version.Version{
BuildTime: buildTime,
Ref: gitRef,
RefName: gitRefName,
RefType: gitRefType,
Sha: gitCommit,
})
a.Assets = appassets.FS()
a.Translations = apptranslations.FS()

if err := a.ReadConfiguration(); err != nil {
return nil, err
}

if err := a.ConfigureDatabase(); err != nil {
return nil, err
}

c := &cli{
app: a,
}

return c, nil
}

func (c *cli) getDatabase() *gorm.DB {
return c.app.DB()
}
27 changes: 27 additions & 0 deletions cmd/wt-debug/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"fmt"
"os"
)

var (
gitRef = "0.0.0-dev"
gitRefName = "local"
gitRefType = "local"
gitCommit = "local"
buildTime = "now"
)

func main() {
c, err := newCLI()
if err != nil {
fmt.Println(err)
os.Exit(1)
}

if err := c.rootCmd().Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
42 changes: 42 additions & 0 deletions cmd/wt-debug/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package main

import (
"fmt"

"github.com/davecgh/go-spew/spew"
"github.com/spf13/cobra"
)

func (c *cli) rootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "wt-debug",
Short: "Workout Tracker debugger is a CLI tool to debug the workout tracker database",
}

cmd.AddCommand(c.versionCmd())
cmd.AddCommand(c.configCmd())
cmd.AddCommand(c.workoutsCmd())

return cmd
}

func (c *cli) versionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Shows the version of the application",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Version: " + c.app.Version.PrettyVersion())
fmt.Println("Build time: " + c.app.Version.BuildTime)
},
}
}

func (c *cli) configCmd() *cobra.Command {
return &cobra.Command{
Use: "config",
Short: "Show the full configuration of the application (including sensitive information)",
Run: func(cmd *cobra.Command, args []string) {
spew.Dump(c.app.Config)
},
}
}
80 changes: 80 additions & 0 deletions cmd/wt-debug/workouts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package main

import (
"os"
"strconv"

"github.com/aquasecurity/table"
"github.com/jovandeginste/workout-tracker/v2/pkg/database"
"github.com/spf13/cobra"
)

func (c *cli) workoutsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "workouts",
Short: "Operate on workouts",
}

cmd.AddCommand(c.workoutsListCmd())
cmd.AddCommand(c.workoutsShowCmd())

return cmd
}

func (c *cli) workoutsListCmd() *cobra.Command {
return &cobra.Command{
Use: "list",
Short: "List all workouts",
RunE: func(cmd *cobra.Command, args []string) error {
t := table.New(os.Stdout)
t.SetHeaders("ID", "Date", "Name")

workouts, err := database.GetWorkouts(c.getDatabase())
if err != nil {
return err
}

for _, wo := range workouts {
t.AddRow(strconv.FormatUint(uint64(wo.ID), 10), wo.Date.String(), wo.Name)
}

t.Render()

return nil
},
}
}

func (c *cli) workoutsShowCmd() *cobra.Command {
return &cobra.Command{
Use: "show",
Short: "Show information about a workout",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
id, err := strconv.Atoi(args[0])
if err != nil {
return err
}

t := table.New(os.Stdout)
t.SetRowLines(false)

wo, err := database.GetWorkout(c.getDatabase(), id)
if err != nil {
return err
}

t.AddRow("ID", strconv.FormatUint(uint64(wo.ID), 10))
t.AddRow("Date", wo.Date.String())
t.AddRow("Name", wo.Name)

t.AddRow("Location", wo.Address())
t.AddRow("Distance (m)", strconv.FormatFloat(wo.TotalDistance(), 'f', 2, 64))
t.AddRow("Duration (s)", strconv.FormatFloat(wo.TotalDuration().Seconds(), 'f', 2, 64))

t.Render()

return nil
},
}
}
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ require (
require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/aquasecurity/table v1.8.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
Expand All @@ -60,6 +61,7 @@ require (
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/invopop/yaml v0.2.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
Expand All @@ -71,20 +73,23 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/philhofer/vec v0.0.0-20140421144027-536fc796d369 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/ringsaturn/tzf-rel-lite v0.0.2024-b // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/samber/lo v1.47.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tidwall/geoindex v1.7.0 // indirect
Expand All @@ -100,7 +105,8 @@ require (
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/time v0.8.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
Expand Down
22 changes: 22 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ github.com/alexedwards/scs/gormstore v0.0.0-20240316134038-7e11d57e8885/go.mod h
github.com/alexedwards/scs/v2 v2.4.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
github.com/alexedwards/scs/v2 v2.8.0 h1:h31yUYoycPuL0zt14c0gd+oqxfRwIj6SOjHdKRZxhEw=
github.com/alexedwards/scs/v2 v2.8.0/go.mod h1:ToaROZxyKukJKT/xLcVQAChi5k6+Pn1Gvmdl7h3RRj8=
github.com/aquasecurity/table v1.8.0 h1:9ntpSwrUfjrM6/YviArlx/ZBGd6ix8W+MtojQcM7tv0=
github.com/aquasecurity/table v1.8.0/go.mod h1:eqOmvjjB7AhXFgFqpJUEE/ietg7RrMSJZXyTN8E/wZw=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/cat-dealer/go-rand/v2 v2.0.0 h1:qTmQ5R61Izk7yc0Si/Onavmr3gK68HeAexoeDc+4e/Q=
Expand All @@ -20,6 +22,7 @@ github.com/codingsince1985/geo-golang v1.8.4 h1:1na/UJ8AVwte9dA/w/Ma+BjdJ8HeHyD4
github.com/codingsince1985/geo-golang v1.8.4/go.mod h1:/XlxmuFwxAK1J+XMt4KRVv2YLlAvJgMELBvZlrD3nzo=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -85,6 +88,8 @@ github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/invopop/ctxi18n v0.9.0 h1:BIia4u4OngaHVn/7gvK0w6lccOXVtad8xU0KgJ+mnVA=
github.com/invopop/ctxi18n v0.9.0/go.mod h1:1Osw+JGYA+anHt0Z4reF36r5FtGHYjGQ+m1X7keIhPc=
github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY=
Expand Down Expand Up @@ -188,6 +193,10 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
Expand Down Expand Up @@ -221,12 +230,17 @@ github.com/ringsaturn/tzf v0.16.0 h1:UsbmJejdUYMjkKzuHPCIigDpTR1uGxw9ThG5NQ98Zdg
github.com/ringsaturn/tzf v0.16.0/go.mod h1:Y4cUannRqEJ3la63hpxjMdUiC1lrxtkml5uocdkeEns=
github.com/ringsaturn/tzf-rel-lite v0.0.2024-b h1:5MSi1siISlO4pZQrQmB+hlJID+ipwvKK6EC33rzcFa8=
github.com/ringsaturn/tzf-rel-lite v0.0.2024-b/go.mod h1:Kb32pggRZUJ06a6Y261pDbVeThW0Pvkr8CWP0ZIMvzg=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3N51bwOk=
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
Expand All @@ -250,6 +264,8 @@ github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI=
Expand Down Expand Up @@ -396,8 +412,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
4 changes: 4 additions & 0 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ func (a *App) createAdminUser() error {

return u.Create(a.db)
}

func (a *App) DB() *gorm.DB {
return a.db
}
4 changes: 2 additions & 2 deletions pkg/database/route_segment_matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
// the route segment
const MaxDeltaMeter = 20.0

// MaxTotalDistancePercentage is the maximum percentage of the total distance of
// MaxTotalDistanceFraction is the maximum percentage of the total distance of
// the route segment that can be exceeded by the total distance matching part of
// the route
// the route (1.0 = 100%)
const MaxTotalDistanceFraction = 0.9

// RouteSegmentMatch is a match between a route segment and a workout
Expand Down
Loading

0 comments on commit 940dbea

Please sign in to comment.