mirror of
https://github.com/SickGear/SickGear.git
synced 2025-01-05 17:43:37 +00:00
Change location of SQL from home template to webserve
Remove unused max_download_count variable
This commit is contained in:
parent
eaa2560a99
commit
d4305eac9f
2 changed files with 23 additions and 34 deletions
|
@ -1,7 +1,7 @@
|
|||
#import sickbeard
|
||||
#import datetime
|
||||
#from sickbeard.common import *
|
||||
#from sickbeard import db, sbdatetime, network_timezones
|
||||
#from sickbeard import sbdatetime, network_timezones
|
||||
|
||||
#set global $title="Home"
|
||||
#set global $header="Show List"
|
||||
|
@ -12,38 +12,6 @@
|
|||
#import os.path
|
||||
#include $os.path.join($sickbeard.PROG_DIR, "gui/slick/interfaces/default/inc_top.tmpl")
|
||||
|
||||
#set $myDB = $db.DBConnection()
|
||||
#set $today = str($datetime.date.today().toordinal())
|
||||
#set $layout = $sickbeard.HOME_LAYOUT
|
||||
|
||||
#set status_quality = '(' + ','.join([str(x) for x in $Quality.SNATCHED + $Quality.SNATCHED_PROPER]) + ')'
|
||||
#set status_download = '(' + ','.join([str(x) for x in $Quality.DOWNLOADED + [$ARCHIVED]]) + ')'
|
||||
|
||||
#set $sql_statement = 'SELECT showid, '
|
||||
|
||||
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN ' + $status_quality + ') AS ep_snatched, '
|
||||
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN ' + $status_download + ') AS ep_downloaded, '
|
||||
|
||||
#set $sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 '
|
||||
#set $sql_statement += ' AND ((airdate <= ' + $today + ' AND (status = ' + str($SKIPPED) + ' OR status = ' + str($WANTED) + ' OR status = ' + str($FAILED) + ')) '
|
||||
#set $sql_statement += ' OR (status IN ' + status_quality + ') OR (status IN ' + status_download + '))) AS ep_total, '
|
||||
|
||||
#set $sql_statement += ' (SELECT airdate FROM tv_episodes WHERE showid=tv_eps.showid AND airdate >= ' + $today + ' AND (status = ' + str($UNAIRED) + ' OR status = ' + str($WANTED) + ') ORDER BY airdate ASC LIMIT 1) AS ep_airs_next '
|
||||
#set $sql_statement += ' FROM tv_episodes tv_eps GROUP BY showid'
|
||||
|
||||
#set $sql_result = $myDB.select($sql_statement)
|
||||
|
||||
#set $show_stat = {}
|
||||
#set $max_download_count = 1000
|
||||
|
||||
#for $cur_result in $sql_result:
|
||||
#set $show_stat[$cur_result['showid']] = $cur_result
|
||||
#if $cur_result['ep_total'] > $max_download_count:
|
||||
#set $max_download_count = $cur_result['ep_total']
|
||||
#end if
|
||||
#end for
|
||||
|
||||
#set $max_download_count = $max_download_count * 100
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
<!--
|
||||
|
|
|
@ -36,7 +36,7 @@ from sickbeard import config, sab, clients, history, notifiers, processTV, ui, l
|
|||
from sickbeard import encodingKludge as ek
|
||||
from sickbeard.providers import newznab, rsstorrent
|
||||
from sickbeard.common import Quality, Overview, statusStrings, qualityPresetStrings, cpu_presets
|
||||
from sickbeard.common import SNATCHED, UNAIRED, IGNORED, ARCHIVED, WANTED, FAILED
|
||||
from sickbeard.common import SNATCHED, UNAIRED, IGNORED, ARCHIVED, WANTED, FAILED, SKIPPED
|
||||
from sickbeard.common import SD, HD720p, HD1080p
|
||||
from sickbeard.exceptions import ex
|
||||
from sickbeard.helpers import remove_article, starify
|
||||
|
@ -583,6 +583,27 @@ class Home(MainHandler):
|
|||
t.showlists = [['Shows', sickbeard.showList]]
|
||||
|
||||
t.submenu = self.HomeMenu()
|
||||
t.layout = sickbeard.HOME_LAYOUT
|
||||
|
||||
# Get all show snatched / downloaded / next air date stats
|
||||
myDB = db.DBConnection()
|
||||
today = datetime.date.today().toordinal()
|
||||
status_quality = ','.join([str(x) for x in Quality.SNATCHED + Quality.SNATCHED_PROPER])
|
||||
status_download = ','.join([str(x) for x in Quality.DOWNLOADED + [ARCHIVED]])
|
||||
status_total = '%s, %s, %s' % (SKIPPED, WANTED, FAILED)
|
||||
|
||||
sql_statement = 'SELECT showid, '
|
||||
sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN (%s)) AS ep_snatched, '
|
||||
sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND status IN (%s)) AS ep_downloaded, '
|
||||
sql_statement += '(SELECT COUNT(*) FROM tv_episodes WHERE showid=tv_eps.showid AND season > 0 AND episode > 0 AND airdate > 1 AND ((airdate <= %s AND (status IN (%s))) OR (status IN (%s)) OR (status IN (%s)))) AS ep_total, '
|
||||
sql_statement += '(SELECT airdate FROM tv_episodes WHERE showid=tv_eps.showid AND airdate >= %s AND (status = %s OR status = %s) ORDER BY airdate ASC LIMIT 1) AS ep_airs_next '
|
||||
sql_statement += ' FROM tv_episodes tv_eps GROUP BY showid'
|
||||
sql_result = myDB.select(sql_statement % (status_quality, status_download, today, status_total, status_quality, status_download, today, UNAIRED, WANTED))
|
||||
|
||||
t.show_stat = {}
|
||||
|
||||
for cur_result in sql_result:
|
||||
t.show_stat[cur_result['showid']] = cur_result
|
||||
|
||||
return t.respond()
|
||||
|
||||
|
|
Loading…
Reference in a new issue