[Amarok] 366dbe7 Fix SqlTrack playcount semantics towards LastFM/FM

Maximilian Kossick maximilian.kossick at googlemail.com
Wed Mar 24 16:40:13 CET 2010


Yes, the other place would be StatisticsProvider.


If it does not know about the lenght of the track yet, it needs to be
added (ideally by just delegating the call from Track to
StatisticsProvider instead of just forwarding it)

On Wed, Mar 24, 2010 at 4:24 PM, Jeff Mitchell <mitchell at kde.org> wrote:
> commit 366dbe78ea69d0dd194222b02ad336b8d7e38428
> Author: Jeff Mitchell <mitchell at kde.org>
> Date:   Wed Mar 24 11:30:43 2010 -0400
>
>    Fix SqlTrack playcount semantics towards LastFM/FMPS rules.
>
>    Max, you said that this would have to be implemented in at least two places, but unless you mean in StatisticsProvider classes (which don't know the length of a track) I didn't find another place.
>
>    CCMAIL:amarok-devel at kde.org
>
> diff --git a/src/collection/sqlcollection/SqlMeta.cpp b/src/collection/sqlcollection/SqlMeta.cpp
> index 7167291..06114cf 100644
> --- a/src/collection/sqlcollection/SqlMeta.cpp
> +++ b/src/collection/sqlcollection/SqlMeta.cpp
> @@ -836,10 +836,22 @@ SqlTrack::finishedPlaying( double playedFraction )
>
>     beginMetaDataUpdate();    // Batch updates, so we only bother our observers once.
>
> -    setPlayCount( newPlayCount );
> -    if( firstPlayed() == 0 )
> -        setFirstPlayed( QDateTime::currentDateTime().toTime_t() );
> -    setLastPlayed( QDateTime::currentDateTime().toTime_t() );
> +    bool doUpdate = false;
> +
> +    if( m_length < 30000 && playedFraction == 1.0 )
> +        doUpdate = true;
> +    if( playedFraction >= 0.5 && m_length >= 30000 ) //song >= 30 seconds and at least half played
> +        doUpdate = true;
> +    if( playedFraction * m_length > 240000 )
> +        doUpdate = true;
> +
> +    if( doUpdate )
> +    {
> +        setPlayCount( newPlayCount );
> +        if( firstPlayed() == 0 )
> +            setFirstPlayed( QDateTime::currentDateTime().toTime_t() );
> +        setLastPlayed( QDateTime::currentDateTime().toTime_t() );
> +    }
>
>     setScore( Amarok::computeScore( score(), newPlayCount, playedFraction ) );
>
> diff --git a/src/collection/sqlcollection/SqlMeta.h b/src/collection/sqlcollection/SqlMeta.h
> index 2a9c6ce..41035e2 100644
> --- a/src/collection/sqlcollection/SqlMeta.h
> +++ b/src/collection/sqlcollection/SqlMeta.h
> @@ -183,7 +183,7 @@ class SqlTrack : public Meta::Track
>         QString m_rpath;
>         int m_trackId;
>
> -        int m_length;
> +        qint64 m_length;
>         qint64 m_filesize;
>         int m_trackNumber;
>         int m_discNumber;
> _______________________________________________
> Amarok-devel mailing list
> Amarok-devel at kde.org
> https://mail.kde.org/mailman/listinfo/amarok-devel
>


More information about the Amarok-devel mailing list