mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-22 13:43:11 +02:00
* DRY: No need to manually load track attributes.
This commit is contained in:
@@ -115,10 +115,10 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
Tomahawk::result_ptr result = Tomahawk::Result::get( url );
|
||||||
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
|
Tomahawk::query_ptr qry = Tomahawk::Query::get( artist, track, album );
|
||||||
|
|
||||||
Tomahawk::track_ptr t = Tomahawk::Track::get( artist, track, album, query.value( 6 ).toUInt(), composer, query.value( 13 ).toUInt(), query.value( 12 ).toUInt() );
|
Tomahawk::track_ptr t = Tomahawk::Track::get( query.value( 16 ).toUInt(), artist, track, album, query.value( 6 ).toUInt(), composer, query.value( 13 ).toUInt(), query.value( 12 ).toUInt() );
|
||||||
|
t->loadAttributes();
|
||||||
result->setTrack( t );
|
result->setTrack( t );
|
||||||
|
|
||||||
result->setTrackId( query.value( 16 ).toUInt() );
|
|
||||||
result->setSize( query.value( 5 ).toUInt() );
|
result->setSize( query.value( 5 ).toUInt() );
|
||||||
result->setBitrate( query.value( 7 ).toUInt() );
|
result->setBitrate( query.value( 7 ).toUInt() );
|
||||||
result->setModificationTime( query.value( 10 ).toUInt() );
|
result->setModificationTime( query.value( 10 ).toUInt() );
|
||||||
@@ -126,19 +126,6 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi )
|
|||||||
result->setScore( 1.0 );
|
result->setScore( 1.0 );
|
||||||
result->setCollection( s->dbCollection() );
|
result->setCollection( s->dbCollection() );
|
||||||
|
|
||||||
TomahawkSqlQuery attrQuery = dbi->newquery();
|
|
||||||
QVariantMap attr;
|
|
||||||
|
|
||||||
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
|
|
||||||
attrQuery.bindValue( 0, result->trackId() );
|
|
||||||
attrQuery.exec();
|
|
||||||
while ( attrQuery.next() )
|
|
||||||
{
|
|
||||||
attr[ attrQuery.value( 0 ).toString() ] = attrQuery.value( 1 ).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
result->setAttributes( attr );
|
|
||||||
|
|
||||||
QList<Tomahawk::result_ptr> results;
|
QList<Tomahawk::result_ptr> results;
|
||||||
results << result;
|
results << result;
|
||||||
qry->addResults( results );
|
qry->addResults( results );
|
||||||
|
@@ -141,28 +141,15 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
track_ptr track = Track::get( files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
||||||
|
track->loadAttributes();
|
||||||
result->setTrack( track );
|
result->setTrack( track );
|
||||||
|
|
||||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||||
result->setSize( files_query.value( 2 ).toUInt() );
|
result->setSize( files_query.value( 2 ).toUInt() );
|
||||||
result->setMimetype( files_query.value( 4 ).toString() );
|
result->setMimetype( files_query.value( 4 ).toString() );
|
||||||
result->setBitrate( files_query.value( 6 ).toUInt() );
|
result->setBitrate( files_query.value( 6 ).toUInt() );
|
||||||
result->setTrackId( files_query.value( 9 ).toUInt() );
|
|
||||||
result->setRID( uuid() );
|
result->setRID( uuid() );
|
||||||
|
|
||||||
TomahawkSqlQuery attrQuery = lib->newquery();
|
|
||||||
QVariantMap attr;
|
|
||||||
|
|
||||||
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
|
|
||||||
attrQuery.bindValue( 0, result->trackId() );
|
|
||||||
attrQuery.exec();
|
|
||||||
while ( attrQuery.next() )
|
|
||||||
{
|
|
||||||
attr[ attrQuery.value( 0 ).toString() ] = attrQuery.value( 1 ).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
result->setAttributes( attr );
|
|
||||||
result->setCollection( s->dbCollection() );
|
result->setCollection( s->dbCollection() );
|
||||||
|
|
||||||
res << result;
|
res << result;
|
||||||
@@ -263,7 +250,8 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
track_ptr track = Track::get( files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() );
|
||||||
|
track->loadAttributes();
|
||||||
result->setTrack( track );
|
result->setTrack( track );
|
||||||
|
|
||||||
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
result->setModificationTime( files_query.value( 1 ).toUInt() );
|
||||||
@@ -271,31 +259,17 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib )
|
|||||||
result->setMimetype( files_query.value( 4 ).toString() );
|
result->setMimetype( files_query.value( 4 ).toString() );
|
||||||
result->setBitrate( files_query.value( 6 ).toUInt() );
|
result->setBitrate( files_query.value( 6 ).toUInt() );
|
||||||
result->setRID( uuid() );
|
result->setRID( uuid() );
|
||||||
result->setTrackId( files_query.value( 9 ).toUInt() );
|
result->setCollection( s->dbCollection() );
|
||||||
|
|
||||||
for ( int k = 0; k < trackPairs.count(); k++ )
|
for ( int k = 0; k < trackPairs.count(); k++ )
|
||||||
{
|
{
|
||||||
if ( trackPairs.at( k ).first == (int)result->trackId() )
|
if ( trackPairs.at( k ).first == (int)track->trackId() )
|
||||||
{
|
{
|
||||||
result->setScore( trackPairs.at( k ).second );
|
result->setScore( trackPairs.at( k ).second );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TomahawkSqlQuery attrQuery = lib->newquery();
|
|
||||||
QVariantMap attr;
|
|
||||||
|
|
||||||
attrQuery.prepare( "SELECT k, v FROM track_attributes WHERE id = ?" );
|
|
||||||
attrQuery.bindValue( 0, result->trackId() );
|
|
||||||
attrQuery.exec();
|
|
||||||
while ( attrQuery.next() )
|
|
||||||
{
|
|
||||||
attr[ attrQuery.value( 0 ).toString() ] = attrQuery.value( 1 ).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
result->setAttributes( attr );
|
|
||||||
result->setCollection( s->dbCollection() );
|
|
||||||
|
|
||||||
res << result;
|
res << result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user