Commit 1430717a authored by echel0n's avatar echel0n
Browse files

Fixed issue #255 - total episode count incorrect.

Improved memory usage from database calls.
Misc code cleanup.
parent f8a371e5
# Changelog
- * 4332f4e - 2018-09-01: Release v9.3.66
- * 9d461c0 - 2018-09-01: Fixed issue #255 - total episode count incorrect. Improved memory usage from database calls. Misc code cleanup.
- * 569f95c - 2018-09-01: Release v9.3.66
- * 33b3f9c - 2018-09-01: Disabled changelog from popping after a new update
- * 4c62c8c - 2018-08-31: Pre-Release v9.3.66.dev2
- * 4ac6773 - 2018-08-31: Pre-Release v9.3.66.dev1
......
......@@ -58,6 +58,7 @@ from sickrage.core.processors.auto_postprocessor import AutoPostProcessor
from sickrage.core.queues.postprocessor import PostProcessorQueue
from sickrage.core.queues.search import SearchQueue
from sickrage.core.queues.show import ShowQueue
from sickrage.core.searchers import get_backlog_cycle_time
from sickrage.core.searchers.backlog_searcher import BacklogSearcher
from sickrage.core.searchers.daily_searcher import DailySearcher
from sickrage.core.searchers.failed_snatch_searcher import FailedSnatchSearcher
......@@ -320,7 +321,7 @@ class Core(object):
self.config.autopostprocessor_freq = self.config.min_autopostprocessor_freq
if self.config.daily_searcher_freq < self.config.min_daily_searcher_freq:
self.config.daily_searcher_freq = self.config.min_daily_searcher_freq
self.config.min_backlog_searcher_freq = self.backlog_searcher.get_backlog_cycle_time()
self.config.min_backlog_searcher_freq = get_backlog_cycle_time()
if self.config.backlog_searcher_freq < self.config.min_backlog_searcher_freq:
self.config.backlog_searcher_freq = self.config.min_backlog_searcher_freq
if self.config.version_updater_freq < self.config.min_version_updater_freq:
......
......@@ -39,6 +39,7 @@ import sickrage
from sickrage.core.common import SD, WANTED, SKIPPED, Quality
from sickrage.core.helpers import makeDir, generate_secret, auto_type, get_lan_ip, \
extract_zipfile, try_int, checkbox_to_value, generateApiKey, backupVersionedFile
from sickrage.core.searchers import get_backlog_cycle_time
from sickrage.core.websession import WebSession
......@@ -1162,7 +1163,7 @@ class Config(object):
:param freq: New frequency
"""
self.backlog_searcher_freq = try_int(freq, self.defaults['General']['backlog_frequency'])
self.min_backlog_searcher_freq = sickrage.app.backlog_searcher.get_backlog_cycle_time()
self.min_backlog_searcher_freq = get_backlog_cycle_time()
if self.backlog_searcher_freq < self.min_backlog_searcher_freq:
self.backlog_searcher_freq = self.min_backlog_searcher_freq
......
......@@ -315,10 +315,18 @@ class srDatabase(object):
os.rename(self.old_db_path + '-shm', '{}-shm.{}_old'.format(self.old_db_path, random))
def all(self, *args, **kwargs):
return [x['doc'] for x in self.db.all(with_doc=True, *args, **kwargs)]
data = [x['doc'] for x in self.db.all(with_doc=True, *args, **kwargs)]
while True:
if not len(data):
break
yield data.pop()
def get_many(self, *args, **kwargs):
return [x['doc'] for x in self.db.get_many(with_doc=True, *args, **kwargs)]
data = [x['doc'] for x in self.db.get_many(with_doc=True, *args, **kwargs)]
while True:
if not len(data):
break
yield data.pop()
def get(self, *args, **kwargs):
x = self.db.get(with_doc=True, *args, **kwargs)
......
......@@ -1569,15 +1569,14 @@ def app_statistics():
if status in status_quality:
show_stat[showid]['ep_snatched'] += 1
overall_stats['episodes']['snatched'] += 1
overall_stats['episodes']['total'] += 1
if status in status_download:
show_stat[showid]['ep_downloaded'] += 1
overall_stats['episodes']['downloaded'] += 1
overall_stats['episodes']['total'] += 1
if (airdate <= today and status in [SKIPPED, WANTED, FAILED]) or (
status in status_quality + status_download):
show_stat[showid]['ep_total'] += 1
overall_stats['episodes']['total'] += 1
if show_stat[showid]['ep_total'] > max_download_count:
max_download_count = show_stat[showid]['ep_total']
......@@ -1588,6 +1587,8 @@ def app_statistics():
show_stat[showid]['ep_airs_prev'] = airdate
show_stat[showid]['total_size'] += epData['file_size']
overall_stats['episodes']['total'] += 1
overall_stats['total_size'] += epData['file_size']
max_download_count *= 100
......
......@@ -22,7 +22,8 @@ from __future__ import unicode_literals
import datetime
import sickrage
from sickrage.core import common, findCertainShow
from sickrage.core import helpers
from sickrage.core.common import UNAIRED, SKIPPED, statusStrings
from sickrage.core.updaters import tz_updater
......@@ -38,11 +39,11 @@ def new_episode_finder():
show = None
for episode in sickrage.app.main_db.all('tv_episodes'):
if not all([episode['status'] == common.UNAIRED, episode['season'] > 0, episode['airdate'] > 1]):
if not all([episode['status'] == UNAIRED, episode['season'] > 0, episode['airdate'] > 1]):
continue
if not show or int(episode["showid"]) != show.indexerid:
show = findCertainShow(int(episode["showid"]))
show = helpers.findCertainShow(int(episode["showid"]))
# for when there is orphaned series in the database but not loaded into our showlist
if not show or show.paused:
......@@ -66,11 +67,15 @@ def new_episode_finder():
ep_obj = show.getEpisode(int(episode['season']), int(episode['episode']))
with ep_obj.lock:
ep_obj.status = show.default_ep_status if ep_obj.season else common.SKIPPED
ep_obj.status = show.default_ep_status if ep_obj.season else SKIPPED
sickrage.app.log.info('Setting status ({status}) for show airing today: {name} {special}'.format(
name=ep_obj.pretty_name(),
status=common.statusStrings[ep_obj.status],
status=statusStrings[ep_obj.status],
special='(specials are not supported)' if not ep_obj.season else '',
))
ep_obj.saveToDB()
\ No newline at end of file
ep_obj.saveToDB()
def get_backlog_cycle_time():
return max([sickrage.app.config.daily_searcher_freq * 4, 30])
\ No newline at end of file
......@@ -110,7 +110,8 @@ class BacklogSearcher(object):
self.amActive = False
def _get_segments(self, show, from_date):
@staticmethod
def _get_segments(show, from_date):
anyQualities, bestQualities = Quality.splitQuality(show.quality)
sickrage.app.log.debug("Seeing if we need anything from {}".format(show.name))
......@@ -147,7 +148,8 @@ class BacklogSearcher(object):
return wanted
def _get_last_backlog_search(self, showid):
@staticmethod
def _get_last_backlog_search(showid):
sickrage.app.log.debug("Retrieving the last check time from the DB")
try:
......@@ -156,12 +158,10 @@ class BacklogSearcher(object):
except:
return 1
def _set_last_backlog_search(self, showid, when):
@staticmethod
def _set_last_backlog_search(showid, when):
sickrage.app.log.debug("Setting the last backlog in the DB to {}".format(when))
dbData = sickrage.app.main_db.get('tv_shows', showid)
dbData['last_backlog_search'] = when
sickrage.app.main_db.update(dbData)
def get_backlog_cycle_time(self):
return max([sickrage.app.config.daily_searcher_freq * 4, 30])
......@@ -62,7 +62,8 @@ class DailySearcher(object):
self.amActive = False
def _get_segments(self, show, fromDate):
@staticmethod
def _get_segments(show, fromDate):
"""
Get a list of episodes that we want to download
:param show: Show these episodes are from
......
......@@ -374,19 +374,17 @@
ep_total = overall_stats['episodes']['total']
ep_percentage = '' if ep_total == 0 else '(<span class="text-primary">%s%%</span>)' % re.sub(r'(\d+)(\.\d)\d+', r'\1\2', str((float(ep_downloaded)/float(ep_total))*100))
%>
<span class="text-primary">${overall_stats['shows']['total']}</span> ${_('Shows')} (<span
class="text-primary">${overall_stats['shows']['active']}</span> ${_('Active')})
<span class="text-primary">${overall_stats['shows']['total']}</span> ${_('Shows')}
(<span class="text-primary">${overall_stats['shows']['active']}</span> ${_('Active')})
| <span class="text-primary">${ep_downloaded}</span>
% if ep_snatched:
<span class="text-primary">
<a href="${srWebRoot}/manage/episodeStatuses?whichStatus=2">+${ep_snatched}</a>
</span>
${_('Snatched')}
% endif
&nbsp;/&nbsp;<span
class="text-primary">${ep_total}</span> ${_('Episodes Downloaded')} ${ep_percentage}
&nbsp;/&nbsp;<span class="text-primary">${total_size}</span> ${_('Overall Downloaded')}
/&nbsp;<span class="text-primary">${ep_total}</span> ${_('Episodes Downloaded')} ${ep_percentage}
/&nbsp;<span class="text-primary">${total_size}</span> ${_('Overall Downloaded')}
% endif
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment