From 81cdcd5bc743b79dbea3cdbfe781d6dd823ded71 Mon Sep 17 00:00:00 2001 From: "Grail Finder (aider)" Date: Sun, 6 Apr 2025 09:49:49 +0300 Subject: feat: implement DBGetQuestionsByMixedID method --- internal/database/repos/questions.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/database/repos/questions.go b/internal/database/repos/questions.go index 4e8ea1e..9d0396e 100644 --- a/internal/database/repos/questions.go +++ b/internal/database/repos/questions.go @@ -9,7 +9,7 @@ type QuestionsRepo interface { DBGetQuestion(id string) (*models.Question, error) DBGetMixedUbung(id uint32) (*models.MixedUbung, error) DBListMixed(limit uint32) ([]models.MixedUbung, error) - DBGetQuestionsByMixedID(id string) ([]models.Question, error) // implement; ai! + DBGetQuestionsByMixedID(id string) ([]models.Question, error) } func (p *Provider) DBGetMixedUbung(id uint32) (*models.MixedUbung, error) { @@ -34,6 +34,15 @@ func (p *Provider) DBListMixed(limit uint32) ([]models.MixedUbung, error) { return ubungs, nil } +func (p *Provider) DBGetQuestionsByMixedID(id string) ([]models.Question, error) { + var questions []models.Question + err := p.db.Select(&questions, "SELECT * FROM questions WHERE mixed_id = ? ORDER BY id", id) + if err != nil { + return nil, err + } + return questions, nil +} + func (p *Provider) DBGetQuestion(id string) (*models.Question, error) { var question models.Question err := p.db.Get(&question, "SELECT * FROM questions WHERE id = ?", id) -- cgit v1.2.3