Commit dc8df9f7 authored by echel0n's avatar echel0n

Mako templates are now rendered on executor, resolves lockups for large renders.

Added detailed list view to main shows page.
Name and quicksearch caches are built during initial show loading.
parent f3a0f0c6
......@@ -78,6 +78,7 @@ Thumbs.db
# Build Files #
######################
.yarn-cache
package-lock.json
/bower_components/
/node_modules/
/src/spritesmith-generated/
......
......@@ -306,6 +306,9 @@ class Core(object):
# load name cache
self.name_cache.load()
# load quicksearch cache
self.quicksearch_cache.load()
if self.config.default_page not in ('schedule', 'history', 'IRC'):
self.config.default_page = 'home'
......@@ -526,8 +529,6 @@ class Core(object):
# fire off startup events
self.scheduler.add_job(self.load_shows)
self.scheduler.add_job(self.quicksearch_cache.run)
self.scheduler.add_job(self.name_cache.run)
self.scheduler.add_job(self.version_updater.run)
self.scheduler.add_job(self.tz_updater.run)
self.scheduler.add_job(self.announcements.run)
......@@ -568,10 +569,11 @@ class Core(object):
self.shows = {}
for show in session.query(MainDB.TVShow).with_entities(MainDB.TVShow.indexer_id, MainDB.TVShow.indexer, MainDB.TVShow.name):
try:
self.log.info('Loading show {} and populating episode cache'.format(show.name))
self.log.info('Loading show {} and building caches'.format(show.name))
show = TVShow(show.indexer_id, show.indexer)
self.name_cache.build(show)
self.quicksearch_cache.add_show(show.indexer_id)
self.shows.update({(show.indexer_id, show.indexer): show})
show.episodes
except Exception as e:
self.log.debug('There was an error loading show: {}'.format(show.name))
......
......@@ -156,7 +156,9 @@ class BaseHandler(RequestHandler, ABC):
return self.mako_lookup.get_template('/errors/500.mako').render_unicode(**template_kwargs)
def render(self, template_name, **kwargs):
return self.write(self.render_string(template_name, **kwargs))
return self.run_task(lambda: self.write(self.render_string(template_name, **kwargs)))
# return self.finish(self.render_string(template_name, **kwargs))
# self.write(self.render_string(template_name, **kwargs))
def set_default_headers(self):
self.set_header("Access-Control-Allow-Origin", "*")
......
......@@ -65,13 +65,14 @@ from sickrage.subtitles import Subtitles
class HomeHandler(BaseHandler, ABC):
@authenticated
async def get(self, *args, **kwargs):
if not len(get_show_list()):
def get(self, *args, **kwargs):
show_list = get_show_list()
if not len(show_list):
return self.redirect('/home/addShows/')
show_lists = OrderedDict({
'Shows': [x for x in get_show_list() if x.anime is False],
'Anime': [x for x in get_show_list() if x.anime is True]
'Shows': [x for x in show_list if x.anime is False],
'Anime': [x for x in show_list if x.anime is True]
})
return self.render(
......
......@@ -105,7 +105,7 @@ class SetHomeLayoutHandler(BaseHandler, ABC):
def get(self, *args, **kwargs):
layout = self.get_argument('layout', 'poster')
if layout not in ('poster', 'small', 'banner', 'simple', 'coverflow'):
if layout not in ('poster', 'small', 'banner', 'simple', 'detailed'):
layout = 'poster'
sickrage.app.config.home_layout = layout
......
Markdown is supported
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