diff options
author | GrailFinder <wohilas@gmail.com> | 2024-06-02 15:00:41 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2024-06-02 15:00:41 +0300 |
commit | 60fc1773241195f4988ed8066e019bbc42267085 (patch) | |
tree | 91dec5a4e298a8b3eb0870649ed8d5031a685001 /internal/database/repos | |
parent | d0ec9f38b17dadf4c244904e28e064d6ad7c5674 (diff) |
Enha: add db method to list recs
Diffstat (limited to 'internal/database/repos')
-rw-r--r-- | internal/database/repos/action.go | 12 |
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 { |