diff options
Diffstat (limited to 'internal/database/repos')
-rw-r--r-- | internal/database/repos/action.go | 10 | ||||
-rw-r--r-- | internal/database/repos/userscore.go | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/internal/database/repos/action.go b/internal/database/repos/action.go index 6024dd5..49ad95e 100644 --- a/internal/database/repos/action.go +++ b/internal/database/repos/action.go @@ -5,6 +5,7 @@ import "apjournal/internal/models" type ActionRepo interface { DBActionCreate(req *models.Action) error DBActionList(username string) ([]models.Action, error) + DBActionGetByName(name string) (*models.Action, error) DBActionDone(name string) error DBActionsToReset() error } @@ -25,6 +26,15 @@ func (p *Provider) DBActionList(username string) ([]models.Action, error) { return resp, nil } +func (p *Provider) DBActionGetByName(name string) (*models.Action, error) { + resp := models.Action{} + query := "SELECT * FROM action WHERE name=$1;" + if err := p.db.Get(&resp, query, name); err != nil { + return nil, err + } + return &resp, nil +} + func (p *Provider) DBActionDone(name string) error { // should reset at burn time stmt := "UPDATE action SET done=true WHERE name=$1;" diff --git a/internal/database/repos/userscore.go b/internal/database/repos/userscore.go index 5c09004..2baf99f 100644 --- a/internal/database/repos/userscore.go +++ b/internal/database/repos/userscore.go @@ -10,8 +10,8 @@ type UserScoreRepo interface { func (p *Provider) DBUserScoreCreate(req *models.UserScore) error { _, err := p.db.NamedExec(` - INSERT INTO user_score(username, burn_time, score) - VALUES (:username, :burn_time, :score);`, req) + INSERT INTO user_score(username, burn_time, score, password) + VALUES (:username, :burn_time, :score, :password);`, req) return err } |