From 558ec2c2e766ad81459ec67bf109bb4f8a31e618 Mon Sep 17 00:00:00 2001 From: Th0rn0 Date: Fri, 27 Sep 2024 14:58:13 +0100 Subject: [PATCH] added creed --- api/helpers.go | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/api/helpers.go b/api/helpers.go index da607ea..ebfc571 100644 --- a/api/helpers.go +++ b/api/helpers.go @@ -44,20 +44,42 @@ func getNextSongExcludeURI(excludeUri spotify.URI) (Track, error) { func getNextSongRandom() (Track, error) { var track Track - if err := db.Raw("SELECT * FROM tracks ORDER BY random()").First(&track).Error; err != nil { + track, err := getNextCreedSong() + if err != nil { + if err := db.Raw("SELECT * FROM tracks ORDER BY random()").First(&track).Error; err != nil { + return track, err + } + } + return track, nil +} + +func getNextCreedSong() (Track, error) { + var track Track + if err := db.Raw("SELECT * FROM tracks WHERE artist == 'Creed' ORDER BY random()").First(&track).Error; err != nil { return track, err } return track, nil } -func getNextSongRandomExcludeURI(excludeUri spotify.URI) (Track, error) { +func getNextCreedSongExcludeURI(excludeUri spotify.URI) (Track, error) { var track Track - if err := db.Raw("SELECT * FROM tracks WHERE uri != ? ORDER BY random()", excludeUri).First(&track).Error; err != nil { + if err := db.Raw("SELECT * FROM tracks WHERE artist == 'Creed' AND uri != ? ORDER BY random()", excludeUri).First(&track).Error; err != nil { return track, err } return track, nil } +func getNextSongRandomExcludeURI(excludeUri spotify.URI) (Track, error) { + var track Track + track, err := getNextCreedSongExcludeURI(excludeUri) + if err != nil { + if err := db.Raw("SELECT * FROM tracks WHERE uri != ? ORDER BY random()", excludeUri).First(&track).Error; err != nil { + return track, err + } + } + return track, nil +} + func getNextSongByVotes() (Track, error) { var track Track if err := db.Raw("SELECT * FROM tracks WHERE votes = ( SELECT MAX(votes) FROM tracks )").First(&track).Error; err != nil {