def backlogOverview(self): t = PageTemplate(rh=self, filename="manage_backlogOverview.mako") showCounts = {} showCats = {} showSQLResults = {} main_db_con = db.DBConnection() for curShow in sickbeard.showList: epCounts = { Overview.SKIPPED: 0, Overview.WANTED: 0, Overview.QUAL: 0, Overview.GOOD: 0, Overview.UNAIRED: 0, Overview.SNATCHED: 0, Overview.SNATCHED_PROPER: 0, Overview.SNATCHED_BEST: 0 } epCats = {} sql_results = main_db_con.select( "SELECT status, season, episode, name, airdate FROM tv_episodes WHERE tv_episodes.season IS NOT NULL " "AND tv_episodes.showid IN (SELECT tv_shows.indexer_id FROM tv_shows WHERE tv_shows.indexer_id = ? " "AND paused = 0) ORDER BY tv_episodes.season DESC, tv_episodes.episode DESC", [curShow.indexerid]) for curResult in sql_results: curEpCat = curShow.getOverview( curResult[b"status"], backlog=sickbeard.BACKLOG_MISSING_ONLY) if curEpCat: epCats['{ep}'.format( ep=episode_num(curResult[b'season'], curResult[b'episode']))] = curEpCat epCounts[curEpCat] += 1 showCounts[curShow.indexerid] = epCounts showCats[curShow.indexerid] = epCats showSQLResults[curShow.indexerid] = sql_results return t.render(showCounts=showCounts, showCats=showCats, showSQLResults=showSQLResults, controller='manage', action='backlogOverview', title=_('Backlog Overview'), header=_('Backlog Overview'), topmenu='manage')
def backlogOverview(self): t = PageTemplate(rh=self, filename="manage_backlogOverview.mako") showCounts = {} showCats = {} showSQLResults = {} main_db_con = db.DBConnection() for curShow in settings.showList: epCounts = { Overview.SKIPPED: 0, Overview.WANTED: 0, Overview.QUAL: 0, Overview.GOOD: 0, Overview.UNAIRED: 0, Overview.SNATCHED: 0, Overview.SNATCHED_PROPER: 0, Overview.SNATCHED_BEST: 0, } epCats = {} sql_results = main_db_con.select( "SELECT status, season, episode, name, airdate FROM tv_episodes WHERE tv_episodes.season IS NOT NULL " "AND tv_episodes.showid IN (SELECT tv_shows.indexer_id FROM tv_shows WHERE tv_shows.indexer_id = ? " "AND paused = 0) ORDER BY tv_episodes.season DESC, tv_episodes.episode DESC", [curShow.indexerid], ) for curResult in sql_results: curEpCat = curShow.getOverview( curResult["status"], backlog=settings.BACKLOG_MISSING_ONLY) if curEpCat: epCats["{ep}".format(ep=episode_num( curResult["season"], curResult["episode"]))] = curEpCat epCounts[curEpCat] += 1 showCounts[curShow.indexerid] = epCounts showCats[curShow.indexerid] = epCats showSQLResults[curShow.indexerid] = sql_results def showQualSnatched(show): return Quality.splitQuality(show.quality)[1] totalWanted = totalQual = totalQualSnatched = 0 backLogShows = sorted( [ x for x in settings.showList if (showCounts[x.indexerid][Overview.QUAL] or showCounts[x.indexerid][Overview.WANTED] or ( 0, showCounts[x.indexerid][Overview.SNATCHED] )[len(showQualSnatched(x)) > 0]) ], key=lambda x: x.sort_name, ) for curShow in backLogShows: totalWanted += showCounts[curShow.indexerid][Overview.WANTED] totalQual += showCounts[curShow.indexerid][Overview.QUAL] if showQualSnatched(curShow): totalQualSnatched += showCounts[curShow.indexerid][ Overview.SNATCHED] return t.render( showCounts=showCounts, showCats=showCats, totalQual=totalQual, showQualSnatched=showQualSnatched, totalWanted=totalWanted, totalQualSnatched=totalQualSnatched, backLogShows=backLogShows, showSQLResults=showSQLResults, controller="manage", action="backlogOverview", title=_("Backlog Overview"), header=_("Backlog Overview"), topmenu="manage", )