def resolve(cls, action, performed): # Store action in history ActionHistory.create(account=action.account_id, session=action.session_id, part=action.part, rating_key=action.rating_key, event=action.event, performed=performed, queued_at=action.queued_at, sent_at=datetime.utcnow()) # Delete queued action cls.delete(action.session_id, action.event)
def is_duplicate(cls, action): if action.event != 'scrobble/stop': return False # Retrieve scrobble duplication period duplication_period = Preferences.get('scrobble.duplication_period') if duplication_period is None: return False # Check for duplicate scrobbles in `duplication_period` scrobbled = ActionHistory.has_scrobbled( action.account, action.rating_key, part=action.part, after=action.queued_at - timedelta(minutes=duplication_period) ) if scrobbled: log.info( 'Ignoring duplicate %r action, scrobble already performed in the last %d minutes', action.event, duplication_period ) return True return False
def resolve(cls, action, performed): # Store action in history ActionHistory.create( account=action.account_id, session=action.session_id, rating_key=action.rating_key, event=action.event, performed=performed, queued_at=action.queued_at, sent_at=datetime.utcnow() ) # Delete queued action cls.delete(action.session_id, action.event)
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
def is_duplicate(cls, action): if action.event != 'scrobble/stop': return False # Retrieve scrobble duplication period duplication_period = Preferences.get('scrobble.duplication_period') if duplication_period is None: return False # Check for duplicate scrobbles in `duplication_period` scrobbled = ActionHistory.has_scrobbled( action.account, action.rating_key, after=action.queued_at - timedelta(minutes=duplication_period) ) if scrobbled: log.info( 'Ignoring duplicate %r action, scrobble already performed in the last %d minutes', action.event, duplication_period ) return True return False