Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Dec 30, 2023
1 parent 0b91e0e commit 339cbfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions internal/db/sqlite.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package db

import (
"sync"
// "sync"

"github.com/jmoiron/sqlx"

Expand All @@ -12,7 +12,7 @@ import (
"github.com/aceberg/ExerciseDiary/internal/models"
)

var mu sync.Mutex
// var mu sync.Mutex

func connect(path string) *sqlx.DB {
dbx, err := sqlx.Connect("sqlite", path)
Expand All @@ -23,21 +23,21 @@ func connect(path string) *sqlx.DB {

func exec(path string, sqlStatement string) {

mu.Lock()
// mu.Lock()
dbx := connect(path)
_, err := dbx.Exec(sqlStatement)
mu.Unlock()
// mu.Unlock()

check.IfError(err)
}

// SelectEx - select all exercises from DB
func SelectEx(path string) (exes []models.Exercise) {

mu.Lock()
// mu.Lock()
dbx := connect(path)
err := dbx.Select(&exes, "SELECT * FROM exercises ORDER BY ID ASC")
mu.Unlock()
// mu.Unlock()

check.IfError(err)

Expand All @@ -47,10 +47,10 @@ func SelectEx(path string) (exes []models.Exercise) {
// SelectSet - select all sets from DB
func SelectSet(path string) (sets []models.Set) {

mu.Lock()
// mu.Lock()
dbx := connect(path)
err := dbx.Select(&sets, "SELECT * FROM sets ORDER BY ID ASC")
mu.Unlock()
// mu.Unlock()

check.IfError(err)

Expand All @@ -60,10 +60,10 @@ func SelectSet(path string) (sets []models.Set) {
// SelectW - select all weight from DB
func SelectW(path string) (w []models.BodyWeight) {

mu.Lock()
// mu.Lock()
dbx := connect(path)
err := dbx.Select(&w, "SELECT * FROM weight ORDER BY ID ASC")
mu.Unlock()
// mu.Unlock()

check.IfError(err)

Expand Down
2 changes: 1 addition & 1 deletion internal/web/templates/exercise.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</tr>
<tr>
<td>Description</td>
<td><textarea name="descr" rows="3" class="form-control" value="{{ .OneEx.Descr }}"></textarea></td>
<td><textarea name="descr" rows="3" class="form-control" value="{{ .OneEx.Descr }}">{{ .OneEx.Descr }}</textarea></td>
</tr>
<tr>
<td>Image link</td>
Expand Down

0 comments on commit 339cbfe

Please sign in to comment.