artists_albums: use tag constraints
authorIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 18:55:45 +0000 (19:55 +0100)
committerIan Beckwith <ianb@erislabs.net>
Sat, 2 Oct 2010 18:55:45 +0000 (19:55 +0100)
lib/ID3FS/DB.pm

index 0ed658c..f0ec02a 100644 (file)
@@ -258,7 +258,7 @@ sub albums
     # FIXME: rework PathElements
     if(ref($constraints[$#constraints]) eq "ID3FS::PathElement::Artist")
     {
-       return $self->artist_albums($constraints[$#constraints]->{id});
+       return $self->artist_albums($constraints[$#constraints]->{id}, @constraints);
     }
     my $sql=("SELECT albums.name\n" .
             "\tFROM (\n" .
@@ -275,8 +275,11 @@ sub albums
 
 sub artist_albums
 {
-    my($self, $artist_id)=@_;
-    my $sql=("SELECT albums.name FROM files\n\t" .
+    my($self, $artist_id, @constraints)=@_;
+    my $sql=("SELECT albums.name FROM (\n" .
+            $self->tags_subselect(@constraints) .
+            "\t) AS subselect\n" .
+            "INNER JOIN files ON subselect.files_id=files.id\n" .
             "INNER JOIN albums ON albums.id=files.albums_id\n\t" .
             "INNER JOIN artists ON artists.id=files.artists_id\n\t" .
             "WHERE artists.id=? and albums.name <> ''\n\t" .