diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index fd234da2..7cd614e0 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -132,12 +132,6 @@
Change the "Play by day of week" graph to start on Monday. Default is start on Sunday.
-Group play history for the same item and user as a single entry when progress is less than the watched percent.
-Decide whether to use end credits markers to determine the 'watched' state of video items. When markers are not available the selected threshold percentage will be used.
+Group play history for the same item and user as a single entry when progress is less than the watched percent.
+
+ Fix grouping of play history in the database.
+
@@ -2484,6 +2497,12 @@ $(document).ready(function() {
confirmAjaxCall(url, msg);
});
+ $("#regroup_history").click(function () {
+ var msg = 'Are you sure you want to regroup play history in the database?';
+ var url = 'regroup_history';
+ confirmAjaxCall(url, msg, null, 'Regrouping play history...');
+ });
+
$("#delete_temp_sessions").click(function () {
var msg = 'Are you sure you want to flush the temporary sessions?
This will reset all currently active sessions.';
var url = 'delete_temp_sessions';
diff --git a/plexpy/activity_processor.py b/plexpy/activity_processor.py
index 6851263b..b1558a56 100644
--- a/plexpy/activity_processor.py
+++ b/plexpy/activity_processor.py
@@ -709,7 +709,8 @@ class ActivityProcessor(object):
def regroup_history(self):
logger.info("Tautulli ActivityProcessor :: Creating database backup...")
- database.make_backup()
+ if not database.make_backup():
+ return False
logger.info("Tautulli ActivityProcessor :: Regrouping session history...")
@@ -720,6 +721,11 @@ class ActivityProcessor(object):
results = self.db.select(query)
for session in results:
- self.group_history(session['id'], session)
+ try:
+ self.group_history(session['id'], session)
+ except Exception as e:
+ logger.error("Tautulli ActivityProcessor :: Error regrouping session history: %s", e)
+ return False
logger.info("Tautulli ActivityProcessor :: Regrouping session history complete.")
+ return True
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 72eb9170..06a9a802 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -51,6 +51,7 @@ if sys.version_info >= (3, 6):
import plexpy
if plexpy.PYTHON2:
import activity_pinger
+ import activity_processor
import common
import config
import database
@@ -85,6 +86,7 @@ if plexpy.PYTHON2:
import macos
else:
from plexpy import activity_pinger
+ from plexpy import activity_processor
from plexpy import common
from plexpy import config
from plexpy import database
@@ -434,6 +436,20 @@ class WebInterface(object):
logger.warn("Unable to retrieve data for get_recently_added.")
return serve_template(template_name="recently_added.html", data=None)
+ @cherrypy.expose
+ @cherrypy.tools.json_out()
+ @requireAuth(member_of("admin"))
+ @addtoapi()
+ def regroup_history(self, **kwargs):
+ """ Regroup play history in the database."""
+
+ result = activity_processor.ActivityProcessor().regroup_history()
+
+ if result:
+ return {'result': 'success', 'message': 'Regrouped play history.'}
+ else:
+ return {'result': 'error', 'message': 'Regrouping play history failed.'}
+
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))