Bug 113044 - Smart Playlist: 2 genres breaks Expand by Year
Summary: Smart Playlist: 2 genres breaks Expand by Year
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.3.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-22 09:37 UTC by HairMetalAddict
Modified: 2006-06-11 12:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description HairMetalAddict 2005-09-22 09:37:53 UTC
Version:           1.3.2 (using KDE KDE 3.4.2)
Installed from:    SuSE RPMs
OS:                Linux

When Creating a Smart Playlist with 2 genres as criteria ("Match any"), and set it to expand by Year, selecting a Year gives songs from any year instead of that specific year.

Works fine with just 1 genre selected. (Unsure about other types of criteria, but definitely a bug with genre.)

Verified by eean on amaroK forums:
 http://amarok.kde.org/component/option,com_simpleboard/Itemid,57/func,view/id,8116/catid,9/ 


DETAILED EXAMPLE (copy of my forum post in above link):

Large MP3 collection, fully MB-tagged plus every MP3 has a genre and year tag hand-added by me.

I want a Random playlist that's only rock or metal, with the ability to select "by year".

I create a Smart Playlist using the following:

 Match *ANY* of the following:
Genre contains "Rock"
Genre contains "Metal"
Order By Random > Completely Random
Limit to 15 Tracks (I've tried no limit or higher limits)
Expand by Year


Now loading the Smart Playlist appears to be giving me what I asked for. No non-rock/metal genres seem to appear.


The problem lies in the "Expand By Year". I Expand the smart playlist and it shows all the available years. Now I've got more than enough songs that would fit in each year so it's not a matter of not having tracks.


What happens? I right-click 1986 for example, and Load.

What I get is songs from every year, as if I loaded the main smart playlist rather than the Expand By sub-entry.
Comment 1 Alexandre Oliveira 2005-09-23 02:46:02 UTC
SVN commit 463103 by aoliveira:

On Smart Playlists, "Expand by" wouldn't work well together with a set of "Match Any" conditions.
BUG: 113044


 M  +8 -4      smartplaylisteditor.cpp  


--- trunk/extragear/multimedia/amarok/src/smartplaylisteditor.cpp #463102:463103
@@ -306,12 +306,13 @@
     QString joins = "tags INNER JOIN year ON year.id=tags.year INNER JOIN genre ON genre.id=tags.genre"
                     " INNER JOIN artist ON artist.id=tags.artist INNER JOIN album ON album.id=tags.album";
     QString whereStr;
+    QString criteriaListStr;
     QString orderStr;
     QString limitStr;
 
     //where expression
     if( m_matchCheck->isChecked() ) {
-        whereStr += " WHERE (";
+        criteriaListStr += " (";
 
         CriteriaEditor *criteria = m_criteriaEditorList.first();
         for( int i=0; criteria; criteria = m_criteriaEditorList.next(), i++ ) {
@@ -331,8 +332,9 @@
                 str.prepend( " " + op + " (");
 
             }
-            whereStr += str+")";
+            criteriaListStr += str+")";
         }
+        whereStr = " WHERE" + criteriaListStr;
     }
 
     //order by expression
@@ -384,8 +386,10 @@
         if( !joins.contains( table ) ) {
             joins += " INNER JOIN statistics ON statistics.url=tags.url";
         }
-        whereStr = QString("%1 AND %1 = \"(*ExpandString*)\"").arg(whereStr).arg(field);
-
+        if ( !criteriaListStr.isEmpty() )
+            whereStr = QString(" WHERE (%1) AND %2 = \"(*ExpandString*)\"").arg(criteriaListStr).arg(field);
+        else
+            whereStr = QString("WHERE %1 = \"(*ExpandString*)\"").arg(field);
         m_expandQuery = "SELECT album.name, artist.name, genre.name, tags.title, year.name, "
                             "tags.comment, tags.track, tags.bitrate, tags.length, tags.samplerate, tags.url"
                             " FROM " + joins + whereStr + orderStr + limitStr + ";";