Exemplo n.º 1
0
    def is_duplicate(cls, action):
        if action.event != 'scrobble/stop':
            return False

        if action.progress < 80:
            return False

        results = ActionHistory.select().where(
            ActionHistory.account == action.account,
            ActionHistory.rating_key == action.rating_key,

            ActionHistory.performed == 'scrobble',

            ActionHistory.sent_at > action.queued_at - timedelta(hours=1)
        )

        if results.count() > 0:
            log.info('Ignoring duplicate %r action, scrobble already performed in the last hour', action.event)
            return True

        return False