diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index 4110c70b..51fdb4e4 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -33,12 +33,15 @@ class DataFactory(object): def __init__(self): pass - def get_datatables_history(self, kwargs=None, custom_where=None, grouping=0, watched_percent=85): + def get_datatables_history(self, kwargs=None, custom_where=None, grouping=None): data_tables = datatables.DataTables() if custom_where is None: custon_where = [] + if grouping is None: + grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES + if session.get_session_user_id(): session_user_id = str(session.get_session_user_id()) added = False @@ -119,6 +122,7 @@ class DataFactory(object): filter_duration = 0 total_duration = self.get_total_duration(custom_where=custom_where) + watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT rows = [] for item in history: diff --git a/plexpy/webserve.py b/plexpy/webserve.py index e3fbc544..d1ef90ca 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -1265,7 +1265,7 @@ class WebInterface(object): @cherrypy.tools.json_out() @requireAuth() @addtoapi() - def get_history(self, user=None, user_id=None, grouping=0, **kwargs): + def get_history(self, user=None, user_id=None, grouping=None, **kwargs): """ Get the PlexPy history. ``` @@ -1350,12 +1350,10 @@ class WebInterface(object): ("watched_status", False, False)] kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "date") - if not grouping or grouping == 'false': + if grouping and str(grouping).isdigit(): + grouping = int(grouping) + elif grouping == 'false': grouping = 0 - else: - grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES - - watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT custom_where = [] if user_id: @@ -1390,7 +1388,7 @@ class WebInterface(object): custom_where.append(['session_history_media_info.transcode_decision', transcode_decision]) data_factory = datafactory.DataFactory() - history = data_factory.get_datatables_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping, watched_percent=watched_percent) + history = data_factory.get_datatables_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping) return history