Commit d2f4387f authored by echel0n's avatar echel0n
Browse files

Decreased time to get series from API V2 endpoint

parent ae57d0dc
......@@ -1428,16 +1428,17 @@ class TVShow(object):
'banner': self.banner
}
# qualities section
json_data['qualities'] = {
'allowedQualities': [x.name for x in self.allowed_qualities],
'preferredQualities': [x.name for x in self.preferred_qualities]
}
# show queue status
json_data['showQueueStatus'] = self.show_queue_status
# detail sections
if details:
# qualities section
json_data['qualities'] = {
'allowedQualities': [x.name for x in self.allowed_qualities],
'preferredQualities': [x.name for x in self.preferred_qualities]
}
# imdb info section
imdb_info = session.query(MainDB.IMDbInfo).filter_by(series_id=self.series_id, imdb_id=self.imdb_id).one_or_none()
json_data['imdbInfo'] = IMDbInfoSchema().dump(imdb_info)
......
......@@ -20,6 +20,7 @@
# ##############################################################################
import os
import re
import time
from itertools import zip_longest
from tornado.escape import json_decode
......@@ -85,23 +86,34 @@ class ApiV2SeriesHandler(ApiV2BaseHandler):
if not series_slug:
all_series = []
# with sickrage.app.main_db.session() as session:
# for series in session.query(MainDB.TVShow).with_entities(MainDB.TVShow.series_id, MainDB.TVShow.series_provider_id, MainDB.TVShow.name):
# json_data = TVShowSchema().dump(series)
# json_data['seriesSlug'] = f'{series.series_id}-{series.series_provider_id}'
# json_data['isLoading'] = False
# json_data['images'] = {
# 'poster': series_image(series.series_id, series.series_provider_id, SeriesImageType.POSTER).url,
# 'banner': ''
# }
#
# all_series.append(json_data)
# start = time.time()
with sickrage.app.main_db.session() as session:
for series in session.query(MainDB.TVShow).with_entities(MainDB.TVShow.series_id, MainDB.TVShow.series_provider_id, MainDB.TVShow.name):
json_data = TVShowSchema().dump(series)
json_data['seriesSlug'] = f'{series.series_id}-{series.series_provider_id.value}'
json_data['isLoading'] = sickrage.app.show_queue.is_being_added(series.series_id)
json_data['isRemoving'] = sickrage.app.show_queue.is_being_removed(series.series_id)
json_data['images'] = {
'poster': series_image(series.series_id, series.series_provider_id, SeriesImageType.POSTER).url,
'banner': series_image(series.series_id, series.series_provider_id, SeriesImageType.BANNER).url
}
all_series.append(json_data)
for show in get_show_list(offset, limit):
if sickrage.app.show_queue.is_being_removed(show.series_id):
continue
# end = time.time()
# print(end - start)
all_series.append(show.to_json(progress=False))
# start = time.time()
#
# for show in get_show_list(offset, limit):
# if show.is_removing:
# continue
#
# all_series.append(show.to_json())
#
# end = time.time()
# print(end - start)
return self.json_response(all_series)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment