Browse Source

Merge branch 'feature/FixLoadingPage' into develop

tags/release_0.25.1
JackDandy 5 years ago
parent
commit
f8023f5344
  1. 36
      sickbeard/webserve.py
  2. 4
      sickbeard/webserveInit.py

36
sickbeard/webserve.py

@ -139,16 +139,8 @@ class PageTemplate(Template):
sickbeard.GUI_NAME, kwargs['file']) sickbeard.GUI_NAME, kwargs['file'])
self.addtab_limit = 9 self.addtab_limit = 9
my_db = db.DBConnection(row_type='dict') if not web_handler.application.is_loading_handler:
history_detailed, history_compact = History.query_history(my_db) self.history_compact = History.menu_tab(self.addtab_limit)
self.history_compact = []
dedupe = set()
for item in history_compact:
if item.get('tvid_prodid') not in dedupe:
dedupe.add(item.get('tvid_prodid'))
self.history_compact += [item]
if self.addtab_limit == len(self.history_compact):
break
super(PageTemplate, self).__init__(*args, **kwargs) super(PageTemplate, self).__init__(*args, **kwargs)
@ -6159,12 +6151,28 @@ class History(MainHandler):
def toggle_help(self): def toggle_help(self):
db.DBConnection().toggle_flag(self.flagname_help_watched) db.DBConnection().toggle_flag(self.flagname_help_watched)
@staticmethod @classmethod
def query_history(my_db, limit=100): def menu_tab(cls, limit):
# type: (db.DBConnection, int, bool) -> Tuple[List[dict], List[dict]]
result = []
my_db = db.DBConnection(row_type='dict') # type: db.DBConnection
history_detailed, history_compact = cls.query_history(my_db, limit)
dedupe = set()
for item in history_compact:
if item.get('tvid_prodid') not in dedupe:
dedupe.add(item.get('tvid_prodid'))
result += [item]
if limit == len(result):
break
return result
@classmethod
def query_history(cls, my_db, limit=100):
# type: (db.DBConnection, int) -> Tuple[List[dict], List[dict]]
"""Query db for historical data """Query db for historical data
:param my_db: dbconnection should be instantiated with row_type='dict' :param my_db: connection should be instantiated with row_type='dict'
:param limit: number of db rows to fetch :param limit: number of db rows to fetch
:return: two data sets, detailed and compact :return: two data sets, detailed and compact
""" """

4
sickbeard/webserveInit.py

@ -26,8 +26,10 @@ class MyApplication(Application):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MyApplication, self).__init__(*args, **kwargs) super(MyApplication, self).__init__(*args, **kwargs)
self.is_loading_handler = False # type: bool
def reset_handlers(self): def reset_handlers(self):
self.is_loading_handler = False
self.wildcard_router = _ApplicationRouter(self, []) self.wildcard_router = _ApplicationRouter(self, [])
self.default_router = _ApplicationRouter(self, [ self.default_router = _ApplicationRouter(self, [
Rule(AnyMatches(), self.wildcard_router) Rule(AnyMatches(), self.wildcard_router)
@ -108,6 +110,7 @@ class WebServer(threading.Thread):
self._add_loading_rules() self._add_loading_rules()
def _add_loading_rules(self): def _add_loading_rules(self):
self.app.is_loading_handler = True
# webui login/logout handlers # webui login/logout handlers
self.app.add_handlers(self.re_host_pattern, [ self.app.add_handlers(self.re_host_pattern, [
(r'%s/login(/?)' % self.options['web_root'], webserve.LoginHandler), (r'%s/login(/?)' % self.options['web_root'], webserve.LoginHandler),
@ -147,6 +150,7 @@ class WebServer(threading.Thread):
self.app.add_handlers(r'.*', [(r'.*', webserve.WrongHostWebHandler)]) self.app.add_handlers(r'.*', [(r'.*', webserve.WrongHostWebHandler)])
def _add_default_rules(self): def _add_default_rules(self):
self.app.is_loading_handler = False
# webui login/logout handlers # webui login/logout handlers
self.app.add_handlers(self.re_host_pattern, [ self.app.add_handlers(self.re_host_pattern, [
(r'%s/login(/?)' % self.options['web_root'], webserve.LoginHandler), (r'%s/login(/?)' % self.options['web_root'], webserve.LoginHandler),

Loading…
Cancel
Save