]> git.ktnx.net Git - mpd-feeder.git/blobdiff - bin/mpd-feeder
fix filtering on album last queue time
[mpd-feeder.git] / bin / mpd-feeder
index 42e3f7bb4516f55e8259ed36a001a89c17bb349a..4c2c537afc08aed1a00312eaf902d093ddb7fe9b 100755 (executable)
@@ -330,11 +330,11 @@ SQL
         $self->update_db;
 
         my @result;
-        my $sth = $db->prepare_cached(<<SQL);
+        my $sql = <<SQL;
 SELECT s.path, s.artist, s.album
 FROM songs s
 JOIN artists ar ON ar.artist=s.artist
-JOIN albums al ON al.album=s.album
+JOIN albums al ON al.album=s.album AND al.artist=s.artist
 WHERE (s.last_queued IS NULL OR s.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
   AND (ar.last_queued IS NULL OR ar.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
   AND (al.last_queued IS NULL OR al.last_queued < CURRENT_TIMESTAMP - (? || ' seconds')::interval)
@@ -343,12 +343,12 @@ WHERE (s.last_queued IS NULL OR s.last_queued < CURRENT_TIMESTAMP - (? || ' seco
 ORDER BY random()
 LIMIT ?
 SQL
-        $sth->execute(
-            $opt->min_song_interval,
-            $opt->min_artist_interval,
-            $opt->min_album_interval,
-            $num,
+        my @params = (
+            $opt->min_song_interval,  $opt->min_artist_interval,
+            $opt->min_album_interval, $num,
         );
+        my $sth = $db->prepare_cached($sql);
+        $sth->execute(@params);
         while ( my @row = $sth->fetchrow_array ) {
             push @result,
                 { song => $row[0], artist => $row[1], album => $row[2] };