summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/database/repos/questions.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/internal/database/repos/questions.go b/internal/database/repos/questions.go
index daf7e16..4e8ea1e 100644
--- a/internal/database/repos/questions.go
+++ b/internal/database/repos/questions.go
@@ -1,11 +1,15 @@
package repos
-import "demoon/internal/models"
+import (
+ "demoon/internal/models"
+ "fmt"
+)
type QuestionsRepo interface {
DBGetQuestion(id string) (*models.Question, error)
DBGetMixedUbung(id uint32) (*models.MixedUbung, error)
- DBGetFirst10MixedUbungs() ([]*models.MixedUbung, error)
+ DBListMixed(limit uint32) ([]models.MixedUbung, error)
+ DBGetQuestionsByMixedID(id string) ([]models.Question, error) // implement; ai!
}
func (p *Provider) DBGetMixedUbung(id uint32) (*models.MixedUbung, error) {
@@ -17,9 +21,13 @@ func (p *Provider) DBGetMixedUbung(id uint32) (*models.MixedUbung, error) {
return &ubung, nil
}
-func (p *Provider) DBGetFirst10MixedUbungs() ([]*models.MixedUbung, error) {
- var ubungs []*models.MixedUbung
- err := p.db.Select(&ubungs, "SELECT * FROM Table_Mixed ORDER BY MixedID LIMIT 10")
+func (p *Provider) DBListMixed(limit uint32) ([]models.MixedUbung, error) {
+ var ubungs []models.MixedUbung
+ query := "SELECT * FROM Table_Mixed ORDER BY MixedID"
+ if limit > 0 {
+ query = fmt.Sprintf("SELECT * FROM Table_Mixed ORDER BY MixedID LIMIT %d", limit)
+ }
+ err := p.db.Select(&ubungs, query)
if err != nil {
return nil, err
}