1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

* Fixed getting year during resolving from database.

This commit is contained in:
Christian Muehlhaeuser
2011-05-25 03:15:15 +02:00
parent 456e57cf20
commit 39b9086d17
2 changed files with 18 additions and 7 deletions

View File

@@ -91,9 +91,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
while( query.next() ) while( query.next() )
{ {
Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result() ); Tomahawk::result_ptr result = Tomahawk::result_ptr( new Tomahawk::Result() );
QVariantMap attr;
TomahawkSqlQuery attrQuery = dbi->newquery();
Tomahawk::source_ptr s; Tomahawk::source_ptr s;
if( query.value( 8 ).toUInt() == 0 ) if( query.value( 8 ).toUInt() == 0 )
@@ -135,6 +132,9 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
result->setScore( 1.0 ); result->setScore( 1.0 );
result->setCollection( s->collection() ); result->setCollection( s->collection() );
TomahawkSqlQuery attrQuery = dbi->newquery();
QVariantMap attr;
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" ); attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
attrQuery.bindValue( 0, result->dbid() ); attrQuery.bindValue( 0, result->dbid() );
attrQuery.exec(); attrQuery.exec();

View File

@@ -88,15 +88,13 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
"file.source, " "file.source, "
"file_join.albumpos, " "file_join.albumpos, "
"artist.id as artid, " "artist.id as artid, "
"album.id as albid, " "album.id as albid "
"track_attributes.v as year " "FROM file, file_join, artist, track "
"FROM file, file_join, artist, track, track_attributes "
"LEFT JOIN album ON album.id = file_join.album " "LEFT JOIN album ON album.id = file_join.album "
"WHERE " "WHERE "
"artist.id = file_join.artist AND " "artist.id = file_join.artist AND "
"track.id = file_join.track AND " "track.id = file_join.track AND "
"file.id = file_join.file AND " "file.id = file_join.file AND "
"file.id = track_attributes.id AND "
"file_join.artist IN (%1) AND " "file_join.artist IN (%1) AND "
"file_join.track IN (%2)" ) "file_join.track IN (%2)" )
.arg( artsl.join( "," ) ) .arg( artsl.join( "," ) )
@@ -144,6 +142,19 @@ DatabaseCommand_Resolve::exec( DatabaseImpl* lib )
result->setId( files_query.value( 9 ).toUInt() ); result->setId( files_query.value( 9 ).toUInt() );
result->setYear( files_query.value( 17 ).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 ); float score = how_similar( m_query, result );
result->setScore( score ); result->setScore( score );
if( score < MINSCORE ) if( score < MINSCORE )