1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-03 20:57:52 +02:00

* Fixed setting timestamp on locally started tracks.

This commit is contained in:
Christian Muehlhaeuser
2013-04-22 10:30:42 +02:00
parent 4737197987
commit 75d02a982d

View File

@@ -68,6 +68,10 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
{ {
Q_ASSERT( !source().isNull() ); Q_ASSERT( !source().isNull() );
unsigned int pt = m_playtime;
if ( m_playtime == 0 )
m_playtime = QDateTime::currentDateTimeUtc().toTime_t();
if ( m_action != Finished ) if ( m_action != Finished )
return; return;
if ( m_secsPlayed < FINISHED_THRESHOLD && m_trackDuration > 0 ) if ( m_secsPlayed < FINISHED_THRESHOLD && m_trackDuration > 0 )
@@ -78,7 +82,7 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id(); QVariant srcid = source()->isLocal() ? QVariant( QVariant::Int ) : source()->id();
TomahawkSqlQuery query = dbi->newquery(); TomahawkSqlQuery query = dbi->newquery();
if ( m_playtime > 0 && source()->isLocal() ) if ( pt > 0 && source()->isLocal() )
{ {
query.prepare( QString( "SELECT * FROM playback_log WHERE source %1 AND playtime = %2" ).arg( srcid.isNull() ? "IS NULL" : srcid.toString() ).arg( m_playtime ) ); query.prepare( QString( "SELECT * FROM playback_log WHERE source %1 AND playtime = %2" ).arg( srcid.isNull() ? "IS NULL" : srcid.toString() ).arg( m_playtime ) );
query.exec(); query.exec();
@@ -89,9 +93,6 @@ DatabaseCommand_LogPlayback::exec( DatabaseImpl* dbi )
} }
} }
if ( m_playtime == 0 )
m_playtime = QDateTime::currentDateTimeUtc().toTime_t();
// tDebug() << "Logging playback of" << m_artist << "-" << m_track << "for source" << srcid << "- timestamp:" << m_playtime; // tDebug() << "Logging playback of" << m_artist << "-" << m_track << "for source" << srcid << "- timestamp:" << m_playtime;
query.prepare( "INSERT INTO playback_log(source, track, playtime, secs_played) VALUES (?, ?, ?, ?)" ); query.prepare( "INSERT INTO playback_log(source, track, playtime, secs_played) VALUES (?, ?, ?, ?)" );