From 39b9086d171219be47674ba58e461354ac778cf3 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Wed, 25 May 2011 03:15:15 +0200 Subject: [PATCH] * Fixed getting year during resolving from database. --- .../database/databasecommand_alltracks.cpp | 6 +++--- .../database/databasecommand_resolve.cpp | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/libtomahawk/database/databasecommand_alltracks.cpp b/src/libtomahawk/database/databasecommand_alltracks.cpp index 01117751c..60d444b33 100644 --- a/src/libtomahawk/database/databasecommand_alltracks.cpp +++ b/src/libtomahawk/database/databasecommand_alltracks.cpp @@ -91,9 +91,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) while( query.next() ) { Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result() ); - - QVariantMap attr; - TomahawkSqlQuery attrQuery = dbi->newquery(); Tomahawk::source_ptr s; if( query.value( 8 ).toUInt() == 0 ) @@ -135,6 +132,9 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) result->setScore( 1.0 ); result->setCollection( s->collection() ); + TomahawkSqlQuery attrQuery = dbi->newquery(); + QVariantMap attr; + attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); attrQuery.bindValue( 0, result->dbid() ); attrQuery.exec(); diff --git a/src/libtomahawk/database/databasecommand_resolve.cpp b/src/libtomahawk/database/databasecommand_resolve.cpp index a9b190ca7..e420f79bb 100644 --- a/src/libtomahawk/database/databasecommand_resolve.cpp +++ b/src/libtomahawk/database/databasecommand_resolve.cpp @@ -88,15 +88,13 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib ) "file.source, " "file_join.albumpos, " "artist.id as artid, " - "album.id as albid, " - "track_attributes.v as year " - "FROM file, file_join, artist, track, track_attributes " + "album.id as albid " + "FROM file, file_join, artist, track " "LEFT JOIN album ON album.id = file_join.album " "WHERE " "artist.id = file_join.artist AND " "track.id = file_join.track AND " "file.id = file_join.file AND " - "file.id = track_attributes.id AND " "file_join.artist IN (%1) AND " "file_join.track IN (%2)" ) .arg( artsl.join( "," ) ) @@ -144,6 +142,19 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib ) result->setId( files_query.value( 9 ).toUInt() ); result->setYear( files_query.value( 17 ).toUInt() ); + TomahawkSqlQuery attrQuery = lib->newquery(); + QVariantMap attr; + + attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); + attrQuery.bindValue( 0, result->dbid() ); + attrQuery.exec(); + while ( attrQuery.next() ) + { + attr[ attrQuery.value( 0 ).toString() ] = attrQuery.value( 1 ).toString(); + } + + result->setAttributes( attr ); + float score = how_similar( m_query, result ); result->setScore( score ); if( score < MINSCORE )