Browse Source

Change move menu history into history.

Change limit data with a webserver app property: is_loading_handler to prevent issues with newly added db datas, e.g. for base PageTemplate during loading page.
tags/release_0.25.1
Prinz23 5 years ago
committed by JackDandy
parent
commit
cb244807d1
  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'])
self.addtab_limit = 9
my_db = db.DBConnection(row_type='dict')
history_detailed, history_compact = History.query_history(my_db)
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
if not web_handler.application.is_loading_handler:
self.history_compact = History.menu_tab(self.addtab_limit)
super(PageTemplate, self).__init__(*args, **kwargs)
@ -6159,12 +6151,28 @@ class History(MainHandler):
def toggle_help(self):
db.DBConnection().toggle_flag(self.flagname_help_watched)
@staticmethod
def query_history(my_db, limit=100):
# type: (db.DBConnection, int, bool) -> Tuple[List[dict], List[dict]]
@classmethod
def menu_tab(cls, limit):
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
: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
:return: two data sets, detailed and compact
"""

4
sickbeard/webserveInit.py

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

Loading…
Cancel
Save