diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index bb4ef1ad..33001bf1 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -51,15 +51,18 @@ class DataFactory(object): def __init__(self): pass - def get_datatables_history(self, kwargs=None, custom_where=None, grouping=None): + def get_datatables_history(self, kwargs=None, custom_where=None, grouping=None, include_activity=None): data_tables = datatables.DataTables() if custom_where is None: - custon_where = [] + custom_where = [] if grouping is None: grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES + if include_activity is None: + include_activity = plexpy.CONFIG.HISTORY_TABLE_ACTIVITY + if session.get_session_user_id(): session_user_id = str(session.get_session_user_id()) added = False @@ -125,7 +128,7 @@ class DataFactory(object): 'NULL AS session_key' ] - if plexpy.CONFIG.HISTORY_TABLE_ACTIVITY: + if include_activity: table_name_union = 'sessions' # Very hacky way to match the custom where parameters for the unioned table custom_where_union = [[c[0].split('.')[-1], c[1]] for c in custom_where] diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 1661211f..67eba4f6 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -1824,7 +1824,7 @@ class WebInterface(object): @requireAuth() @sanitize_out() @addtoapi() - def get_history(self, user=None, user_id=None, grouping=None, **kwargs): + def get_history(self, user=None, user_id=None, grouping=None, include_activity=None, **kwargs): """ Get the Tautulli history. ``` @@ -1833,6 +1833,7 @@ class WebInterface(object): Optional parameters: grouping (int): 0 or 1 + include_activity (int): 0 or 1 user (str): "Jon Snow" user_id (int): 133788 rating_key (int): 4348 @@ -1921,6 +1922,7 @@ class WebInterface(object): kwargs['json_data'] = build_datatables_json(kwargs, dt_columns, "date") grouping = helpers.bool_true(grouping, return_none=True) + include_activity = helpers.bool_true(include_activity, return_none=True) custom_where = [] if user_id: @@ -1961,7 +1963,8 @@ class WebInterface(object): custom_where.append(['session_history_metadata.guid', 'LIKE ' + guid + '%']) # SQLite LIKE wildcard data_factory = datafactory.DataFactory() - history = data_factory.get_datatables_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping) + history = data_factory.get_datatables_history(kwargs=kwargs, custom_where=custom_where, + grouping=grouping, include_activity=include_activity) return history