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.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/database/repos/action.go b/internal/database/repos/action.go
index 49ad95e..ab1f559 100644
--- a/internal/database/repos/action.go
+++ b/internal/database/repos/action.go
@@ -8,6 +8,18 @@ type ActionRepo interface {
DBActionGetByName(name string) (*models.Action, error)
DBActionDone(name string) error
DBActionsToReset() error
+ DBActionRecommend(username string, at models.ActionType) ([]models.Action, error)
+}
+
+func (p *Provider) DBActionRecommend(
+ username string, at models.ActionType,
+) ([]models.Action, error) {
+ resp := []models.Action{}
+ query := `SELECT * FROM action WHERE username!=$1 AND type=$2 GROUP BY name LIMIT 5;`
+ if err := p.db.Select(&resp, query, username, at); err != nil {
+ return nil, err
+ }
+ return resp, nil
}
func (p *Provider) DBActionCreate(req *models.Action) error {