mirror of
https://github.com/morpheus65535/bazarr
synced 2025-02-28 16:45:40 +00:00
Removed hardcoded table relations in joins.
This commit is contained in:
parent
438392c1fd
commit
c98c0d3811
3 changed files with 28 additions and 28 deletions
|
@ -290,7 +290,7 @@ class Badges(Resource):
|
|||
missing_episodes = TableEpisodes.select(TableShows.tags,
|
||||
TableShows.seriesType,
|
||||
TableEpisodes.monitored)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, episodes_conditions))\
|
||||
.count()
|
||||
|
||||
|
@ -639,7 +639,7 @@ class Series(Resource):
|
|||
episodeMissingCount = TableEpisodes.select(TableShows.tags,
|
||||
TableEpisodes.monitored,
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, episodes_missing_conditions))\
|
||||
.count()
|
||||
item.update({"episodeMissingCount": episodeMissingCount})
|
||||
|
@ -648,7 +648,7 @@ class Series(Resource):
|
|||
episodeFileCount = TableEpisodes.select(TableShows.tags,
|
||||
TableEpisodes.monitored,
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(TableEpisodes.seriesId == item['seriesId'])\
|
||||
.count()
|
||||
item.update({"episodeFileCount": episodeFileCount})
|
||||
|
@ -1358,7 +1358,7 @@ class ProviderEpisodes(Resource):
|
|||
episodeInfo = TableEpisodes.select(TableEpisodes.title,
|
||||
TableEpisodes.path,
|
||||
TableShows.profileId) \
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(TableEpisodes.episodeId == episodeId) \
|
||||
.dicts() \
|
||||
.get()
|
||||
|
@ -1460,8 +1460,8 @@ class EpisodesHistory(Resource):
|
|||
TableShows.tags,
|
||||
TableEpisodes.monitored,
|
||||
TableShows.seriesType)\
|
||||
.join(TableEpisodes, on=(TableHistory.episodeId == TableEpisodes.episodeId))\
|
||||
.join(TableShows, on=(TableHistory.seriesId == TableShows.seriesId))\
|
||||
.join(TableEpisodes) \
|
||||
.join(TableShows) \
|
||||
.where(reduce(operator.and_, upgradable_episodes_conditions))\
|
||||
.group_by(TableHistory.video_path)\
|
||||
.dicts()
|
||||
|
@ -1498,8 +1498,8 @@ class EpisodesHistory(Resource):
|
|||
TableHistory.episodeId,
|
||||
TableHistory.provider,
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableHistory.seriesId == TableShows.seriesId))\
|
||||
.join(TableEpisodes, on=(TableHistory.episodeId == TableEpisodes.episodeId))\
|
||||
.join(TableEpisodes) \
|
||||
.join(TableShows) \
|
||||
.where(query_condition)\
|
||||
.order_by(TableHistory.timestamp.desc())\
|
||||
.limit(length)\
|
||||
|
@ -1542,7 +1542,7 @@ class EpisodesHistory(Resource):
|
|||
break
|
||||
|
||||
count = TableHistory.select()\
|
||||
.join(TableEpisodes, on=(TableHistory.episodeId == TableEpisodes.episodeId))\
|
||||
.join(TableEpisodes)\
|
||||
.where(TableEpisodes.title is not None).count()
|
||||
|
||||
return jsonify(data=episode_history, total=count)
|
||||
|
@ -1576,7 +1576,7 @@ class MoviesHistory(Resource):
|
|||
TableHistoryMovie.score,
|
||||
TableMovies.tags,
|
||||
TableMovies.monitored)\
|
||||
.join(TableMovies, on=(TableHistoryMovie.movieId == TableMovies.movieId))\
|
||||
.join(TableMovies)\
|
||||
.where(reduce(operator.and_, upgradable_movies_conditions))\
|
||||
.group_by(TableHistoryMovie.video_path)\
|
||||
.dicts()
|
||||
|
@ -1611,7 +1611,7 @@ class MoviesHistory(Resource):
|
|||
TableHistoryMovie.subs_id,
|
||||
TableHistoryMovie.provider,
|
||||
TableHistoryMovie.subtitles_path)\
|
||||
.join(TableMovies, on=(TableHistoryMovie.movieId == TableMovies.movieId))\
|
||||
.join(TableMovies)\
|
||||
.where(query_condition)\
|
||||
.order_by(TableHistoryMovie.timestamp.desc())\
|
||||
.limit(length)\
|
||||
|
@ -1653,7 +1653,7 @@ class MoviesHistory(Resource):
|
|||
break
|
||||
|
||||
count = TableHistoryMovie.select()\
|
||||
.join(TableMovies, on=(TableHistoryMovie.movieId == TableMovies.movieId))\
|
||||
.join(TableMovies)\
|
||||
.where(TableMovies.title is not None)\
|
||||
.count()
|
||||
|
||||
|
@ -1753,7 +1753,7 @@ class EpisodesWanted(Resource):
|
|||
TableShows.tags,
|
||||
TableEpisodes.failedAttempts,
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(wanted_condition)\
|
||||
.dicts()
|
||||
else:
|
||||
|
@ -1769,7 +1769,7 @@ class EpisodesWanted(Resource):
|
|||
TableShows.tags,
|
||||
TableEpisodes.failedAttempts,
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(wanted_condition)\
|
||||
.order_by(TableEpisodes.episodeId.desc())\
|
||||
.limit(length)\
|
||||
|
@ -1785,7 +1785,7 @@ class EpisodesWanted(Resource):
|
|||
count = TableEpisodes.select(TableShows.tags,
|
||||
TableShows.seriesType,
|
||||
TableEpisodes.monitored)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, count_conditions))\
|
||||
.count()
|
||||
|
||||
|
@ -1859,8 +1859,8 @@ class EpisodesBlacklist(Resource):
|
|||
TableBlacklist.subs_id,
|
||||
TableBlacklist.language,
|
||||
TableBlacklist.timestamp)\
|
||||
.join(TableEpisodes, on=(TableBlacklist.episode_id == TableEpisodes.episodeId))\
|
||||
.join(TableShows, on=(TableBlacklist.series_id == TableShows.seriesId))\
|
||||
.join(TableEpisodes)\
|
||||
.join(TableShows)\
|
||||
.order_by(TableBlacklist.timestamp.desc())\
|
||||
.limit(length)\
|
||||
.offset(start)\
|
||||
|
@ -1935,7 +1935,7 @@ class MoviesBlacklist(Resource):
|
|||
TableBlacklistMovie.subs_id,
|
||||
TableBlacklistMovie.language,
|
||||
TableBlacklistMovie.timestamp)\
|
||||
.join(TableMovies, on=(TableBlacklistMovie.movie_id == TableMovies.movieId))\
|
||||
.join(TableMovies)\
|
||||
.order_by(TableBlacklistMovie.timestamp.desc())\
|
||||
.limit(length)\
|
||||
.offset(start)\
|
||||
|
@ -2128,7 +2128,7 @@ class WebHooksPlex(Resource):
|
|||
return '', 404
|
||||
else:
|
||||
episodeId = TableEpisodes.select(TableEpisodes.episodeId) \
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId)) \
|
||||
.join(TableShows) \
|
||||
.where(TableShows.imdbId == series_imdb_id,
|
||||
TableEpisodes.season == season,
|
||||
TableEpisodes.episode == episode) \
|
||||
|
|
|
@ -704,7 +704,7 @@ def series_download_subtitles(no):
|
|||
TableEpisodes.season,
|
||||
TableEpisodes.episode,
|
||||
TableEpisodes.title.alias('episodeTitle'))\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, conditions))\
|
||||
.dicts()
|
||||
if not episodes_details:
|
||||
|
@ -793,7 +793,7 @@ def episode_download_subtitles(no, send_progress=False):
|
|||
TableEpisodes.title.alias('episodeTitle'),
|
||||
TableEpisodes.season,
|
||||
TableEpisodes.episode)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, conditions))\
|
||||
.dicts()
|
||||
if not episodes_details:
|
||||
|
@ -954,7 +954,7 @@ def wanted_download_subtitles(episode_id):
|
|||
TableEpisodes.audio_language,
|
||||
TableEpisodes.failedAttempts,
|
||||
TableShows.title)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where((TableEpisodes.episodeId == episode_id))\
|
||||
.dicts()
|
||||
episodes_details = list(episodes_details)
|
||||
|
@ -1124,7 +1124,7 @@ def wanted_search_missing_subtitles_series():
|
|||
TableEpisodes.episode,
|
||||
TableEpisodes.title.alias('episodeTitle'),
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(reduce(operator.and_, conditions))\
|
||||
.dicts()
|
||||
episodes = list(episodes)
|
||||
|
@ -1223,7 +1223,7 @@ def refine_from_db(path, video):
|
|||
TableEpisodes.audio_codec,
|
||||
TableEpisodes.path,
|
||||
TableShows.imdbId)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where((TableEpisodes.path == path))\
|
||||
.dicts()
|
||||
|
||||
|
@ -1365,8 +1365,8 @@ def upgrade_subtitles():
|
|||
TableEpisodes.episode,
|
||||
TableShows.title.alias('seriesTitle'),
|
||||
TableShows.seriesType)\
|
||||
.join(TableShows, on=(TableHistory.seriesId == TableShows.seriesId))\
|
||||
.join(TableEpisodes, on=(TableHistory.episodeId == TableEpisodes.episodeId))\
|
||||
.join(TableEpisodes) \
|
||||
.join(TableShows) \
|
||||
.where(reduce(operator.and_, upgradable_episodes_conditions))\
|
||||
.group_by(TableHistory.video_path, TableHistory.language)\
|
||||
.dicts()
|
||||
|
@ -1406,7 +1406,7 @@ def upgrade_subtitles():
|
|||
TableMovies.tags,
|
||||
TableMovies.movieId,
|
||||
TableMovies.title)\
|
||||
.join(TableMovies, on=(TableHistoryMovie.movieId == TableMovies.movieId))\
|
||||
.join(TableMovies)\
|
||||
.where(reduce(operator.and_, upgradable_movies_conditions))\
|
||||
.group_by(TableHistoryMovie.video_path, TableHistoryMovie.language)\
|
||||
.dicts()
|
||||
|
|
|
@ -241,7 +241,7 @@ def list_missing_subtitles(no=None, epno=None, send_event=True):
|
|||
TableEpisodes.subtitles,
|
||||
TableShows.profileId,
|
||||
TableEpisodes.audio_language)\
|
||||
.join(TableShows, on=(TableEpisodes.seriesId == TableShows.seriesId))\
|
||||
.join(TableShows)\
|
||||
.where(episodes_subtitles_clause)\
|
||||
.dicts()
|
||||
if isinstance(episodes_subtitles, str):
|
||||
|
|
Loading…
Reference in a new issue