1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-23 09:19:41 +01: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() );
unsigned int pt = m_playtime;
if ( m_playtime == 0 )
m_playtime = QDateTime::currentDateTimeUtc().toTime_t();
if ( m_action != Finished )
return;
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();
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.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;
query.prepare( "INSERT INTO playback_log(source, track, playtime, secs_played) VALUES (?, ?, ?, ?)" );