Skip to content

Commit

Permalink
sql random
Browse files Browse the repository at this point in the history
  • Loading branch information
th0rn0 committed May 3, 2024
1 parent 936e447 commit a851701
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
func getNextSong() (Track, error) {
var nextTrack Track
var err error
// if voteToSkipEnabled {
// nextTrack, err = getNextSongRandom()
// } else {
if voteToSkipEnabled {
nextTrack, err = getNextSongRandom()
} else {
nextTrack, err = getNextSongByVotes()
// }
}
if err != nil {
// Assume no record - get from fallback playlist
nextTrack = assignFallback(nextTrack)
Expand All @@ -40,7 +40,7 @@ func getNextSongExcludeURI(excludeUri spotify.URI) (Track, error) {

func getNextSongRandom() (Track, error) {
var track Track
if err := db.Raw("SELECT * FROM tracks ORDER BY RAND()").First(&track).Error; err != nil {
if err := db.Raw("SELECT * FROM tracks ORDER BY random()").First(&track).Error; err != nil {
return track, err
}
return track, nil
Expand Down

0 comments on commit a851701

Please sign in to comment.