SickGear/gui/slick/interfaces/default/inc_bottom.tmpl
Prinz23 53f272515a Fix Backlog Init
Fix the limited backlog to execute as and when expected and in line with SickBeard.

The backlog scheduled frequency is the higher of either 12 hours or 2 x the "Recent search frequency" + 7 minutes.

On application startup and every backlog scheduled frequency the backlog will either ...
a) do a full run if the number of days passed since the full backlog has reached the setting(1)...
b) do a limited run if the number of days passed since the full backlog is less than setting(1)...
... (1) "Backlog search frequency" in Search Settings.

Change the default full "Backlog search frequency" to 21 days within a range of 2 - 35 (see Search Settings).
2015-04-15 17:47:04 +02:00

71 lines
2.9 KiB
Cheetah

#import sickbeard
#import datetime
#import re
#from sickbeard import db, sbdatetime
#from sickbeard.common import *
</div> <!-- /content -->
</div> <!-- /contentWrapper -->
<footer>
<div class="footer clearfix">
#set $my_db = $db.DBConnection()
#set $today = str($datetime.date.today().toordinal())
#set status_quality = '(%s)' % ','.join([str(quality) for quality in $Quality.SNATCHED + $Quality.SNATCHED_PROPER])
#set status_download = '(%s)' % ','.join([str(quality) for quality in $Quality.DOWNLOADED + [$ARCHIVED]])
#set $sql_statement = 'SELECT '\
+ '(SELECT COUNT(*) FROM tv_episodes WHERE season > 0 AND episode > 0 AND airdate > 1 AND status IN %s) AS ep_snatched, '\
% $status_quality\
+ '(SELECT COUNT(*) FROM tv_episodes WHERE season > 0 AND episode > 0 AND airdate > 1 AND status IN %s) AS ep_downloaded, '\
% $status_download\
+ '(SELECT COUNT(*) FROM tv_episodes WHERE season > 0 AND episode > 0 AND airdate > 1 '\
+ ' AND ((airdate <= %s AND (status = %s OR status = %s)) '\
% ($today, str($SKIPPED), str($WANTED))\
+ ' OR (status IN %s) OR (status IN %s))) AS ep_total FROM tv_episodes tv_eps LIMIT 1'\
% ($status_quality, $status_download)
#slurp
#set $sql_result = $my_db.select($sql_statement)
#slurp
#set $shows_total = len($sickbeard.showList)
#set $shows_active = len([show for show in $sickbeard.showList if 0 == show.paused and 'Ended' != show.status])
#slurp
#if $sql_result:
#set $ep_snatched = $sql_result[0]['ep_snatched']
#set $ep_downloaded = $sql_result[0]['ep_downloaded']
#set $ep_total = $sql_result[0]['ep_total']
#else
#set $ep_snatched = 0
#set $ep_downloaded = 0
#set $ep_total = 0
#end if
#set $ep_percentage = '' if $ep_total == 0 else '(<span class="footerhighlight">%s%%</span>)' % re.sub(r'(\d+)(\.\d)\d+', r'\1\2', str((float($ep_downloaded)/float($ep_total))*100))
#slurp
#try
#set $localRoot = $sbRoot
#except NotFound
#set $localRoot = ''
#end try
#try
#set $localheader = $header
#except NotFound
#set $localheader = ''
#end try
#slurp
<span class="footerhighlight">$shows_total</span> shows (<span class="footerhighlight">$shows_active</span> active)
| <span class="footerhighlight">$ep_downloaded</span><%=
(
'',
' (<span class="footerhighlight">+%s</span> snatched)'\
% '<a href="%s/manage/episodeStatuses?whichStatus=2" title="View overview of snatched episodes">%s</a>'
% (localRoot, str(ep_snatched))
)[0 < ep_snatched]
%>&nbsp;/&nbsp;<span class="footerhighlight">$ep_total</span> episodes downloaded $ep_percentage
| recent search: <span class="footerhighlight"><%= str(sickbeard.recentSearchScheduler.timeLeft()).split('.')[0] %></span>
| backlog search: <span class="footerhighlight"><%= str(sickbeard.backlogSearchScheduler.timeLeft()).split('.')[0] %></span>
| full backlog: <span class="footerhighlight"><%= sbdatetime.sbdatetime.sbfdate(sickbeard.backlogSearchScheduler.nextRun()) %></span>
#slurp
</div>
</footer>
</body>
</html>