From 01f9a9f5d71450a0c80195058245fdebe88796bd Mon Sep 17 00:00:00 2001 From: GrailFinder Date: Wed, 5 Jun 2024 08:22:36 +0300 Subject: Feat: recommendations for anon and user --- internal/database/repos/action.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'internal/database/repos') diff --git a/internal/database/repos/action.go b/internal/database/repos/action.go index ab1f559..38253bc 100644 --- a/internal/database/repos/action.go +++ b/internal/database/repos/action.go @@ -8,15 +8,15 @@ type ActionRepo interface { DBActionGetByName(name string) (*models.Action, error) DBActionDone(name string) error DBActionsToReset() error - DBActionRecommend(username string, at models.ActionType) ([]models.Action, error) + DBActionRecommend(username string) ([]models.Action, error) } func (p *Provider) DBActionRecommend( - username string, at models.ActionType, + username string, ) ([]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 { + query := `SELECT * FROM action WHERE name NOT IN (select name from action where username == $1) GROUP BY name LIMIT 100;` + if err := p.db.Select(&resp, query, username); err != nil { return nil, err } return resp, nil -- cgit v1.2.3