Fixed more peewee implementation issues.

pull/1419/head v0.9.6-beta.13
morpheus65535 4 years ago
parent 9cc00ebd65
commit f442d7d091

@ -318,7 +318,10 @@ class Badges(Resource):
episodes_conditions = [(TableEpisodes.missing_subtitles is not None),
(TableEpisodes.missing_subtitles != '[]')]
episodes_conditions += get_exclusion_clause('series')
missing_episodes = TableEpisodes.select().where(reduce(operator.and_, episodes_conditions)).count()
missing_episodes = TableEpisodes.select(TableShows.tags, TableShows.seriesType)\
.join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId))\
.where(reduce(operator.and_, episodes_conditions))\
.count()
movies_conditions = [(TableMovies.missing_subtitles is not None),
(TableMovies.missing_subtitles != '[]')]
@ -636,14 +639,11 @@ class Series(Resource):
item.update({"episodeMissingCount": episodeMissingCount})
# Add episode count
episodes_count_conditions = [(TableEpisodes.sonarrSeriesId == item['sonarrSeriesId'])]
episodes_count_conditions += get_exclusion_clause('series')
episodeFileCount = TableEpisodes.select(TableShows.tags,
TableEpisodes.monitored,
TableShows.seriesType)\
.join(TableShows, on=(TableEpisodes.sonarrSeriesId == TableShows.sonarrSeriesId))\
.where(reduce(operator.and_, episodes_count_conditions))\
.where(TableEpisodes.sonarrSeriesId == item['sonarrSeriesId'])\
.count()
item.update({"episodeFileCount": episodeFileCount})

@ -294,11 +294,11 @@ def get_exclusion_clause(exclusion_type):
if exclusion_type == 'series':
tagsList = ast.literal_eval(settings.sonarr.excluded_tags)
for tag in tagsList:
where_clause.append(~(TableShows.tags ** tag))
where_clause.append(~(TableShows.tags.contains("\'"+tag+"\'")))
else:
tagsList = ast.literal_eval(settings.radarr.excluded_tags)
for tag in tagsList:
where_clause.append(~(TableMovies.tags ** tag))
where_clause.append(~(TableMovies.tags.contains("\'"+tag+"\'")))
if exclusion_type == 'series':
monitoredOnly = settings.sonarr.getboolean('only_monitored')

@ -161,20 +161,6 @@ def update_movies(send_event=True):
logging.debug('BAZARR All movies synced from Radarr into database.')
# Search for desired subtitles if no more than 5 movies have been added.
if len(altered_movies) <= 5:
logging.debug("BAZARR No more than 5 movies were added during this sync then we'll search for subtitles.")
for altered_movie in altered_movies:
conditions = [(TableMovies.radarrId == altered_movie[2])]
conditions += get_exclusion_clause('movie')
data = TableMovies.get(reduce(operator.and_, conditions))
if data:
movies_download_subtitles(data['radarrId'])
else:
logging.debug("BAZARR skipping download for this movie as it is excluded.")
else:
logging.debug("BAZARR More than 5 movies were added during this sync then we wont search for subtitles.")
def update_one_movie(movie_id, action):
logging.debug('BAZARR syncing this specific movie from Radarr: {}'.format(movie_id))

Loading…
Cancel
Save