mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Regroup history in separate thread and improve logging
This commit is contained in:
parent
343a3e9281
commit
d91e561a56
3 changed files with 16 additions and 8 deletions
|
@ -719,8 +719,14 @@ class ActivityProcessor(object):
|
|||
"JOIN session_history_metadata ON session_history.id = session_history_metadata.id"
|
||||
)
|
||||
results = self.db.select(query)
|
||||
count = len(results)
|
||||
progress = 0
|
||||
|
||||
for i, session in enumerate(results, start=1):
|
||||
if int(i / count * 10) > progress:
|
||||
progress = int(i / count * 10)
|
||||
logger.info("Tautulli ActivityProcessor :: Regrouping session history: %d%%", progress * 10)
|
||||
|
||||
for session in results:
|
||||
try:
|
||||
self.group_history(session['id'], session)
|
||||
except Exception as e:
|
||||
|
@ -729,3 +735,7 @@ class ActivityProcessor(object):
|
|||
|
||||
logger.info("Tautulli ActivityProcessor :: Regrouping session history complete.")
|
||||
return True
|
||||
|
||||
|
||||
def regroup_history():
|
||||
ActivityProcessor().regroup_history()
|
||||
|
|
|
@ -443,12 +443,10 @@ class WebInterface(object):
|
|||
def regroup_history(self, **kwargs):
|
||||
""" Regroup play history in the database."""
|
||||
|
||||
result = activity_processor.ActivityProcessor().regroup_history()
|
||||
threading.Thread(target=activity_processor.regroup_history).start()
|
||||
|
||||
if result:
|
||||
return {'result': 'success', 'message': 'Regrouped play history.'}
|
||||
else:
|
||||
return {'result': 'error', 'message': 'Regrouping play history failed.'}
|
||||
return {'result': 'success',
|
||||
'message': 'Regrouping play history started. Check the logs to monitor any problems.'}
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue