Skip to content

Commit

Permalink
History records are now removed in batches of 200 items to avoid read…
Browse files Browse the repository at this point in the history
… timeouts
  • Loading branch information
fuzeman committed Sep 18, 2016
1 parent db7e82a commit 0c4c899
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions trakt_tools/tasks/history/duplicates/merge/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

from trakt import Trakt, ClientError, ServerError
import logging
import six

log = logging.getLogger(__name__)


class Executor(object):
def __init__(self, review=True):
def __init__(self, review=True, batch_size=200):
self.review = review
self.batch_size = batch_size

def process_shows(self, profile, shows):
log.debug('Executing actions on %d shows...', len(shows))
Expand All @@ -34,7 +36,8 @@ def process_shows(self, profile, shows):
continue

# Remove history records
self._remove_records(ids)
for x in six.moves.xrange(0, len(ids), self.batch_size):
self._remove_records(ids[x:x + self.batch_size])

print()
print('-' * 70)
Expand All @@ -60,7 +63,8 @@ def process_movies(self, profile, movies):
continue

# Remove history records
self._remove_records(ids)
for x in six.moves.xrange(0, len(ids), self.batch_size):
self._remove_records(ids[x:x + self.batch_size])

print()
print('-' * 70)
Expand Down

0 comments on commit 0c4c899

Please sign in to comment.