summaryrefslogtreecommitdiff
path: root/internal/database/repos/action.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/database/repos/action.go')
-rw-r--r--internal/database/repos/action.go10
1 files changed, 10 insertions, 0 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;"