mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-22 06:13:25 -07:00
Move make_user_cond at bottom and make private
This commit is contained in:
parent
f8943176e0
commit
7a9dc6d43b
1 changed files with 24 additions and 24 deletions
|
@ -51,7 +51,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -161,26 +161,13 @@ class Graphs(object):
|
|||
'series': series_output}
|
||||
return output
|
||||
|
||||
def make_user_cond(self, user_id):
|
||||
"""
|
||||
Expects user_id to be a comma-separated list of ints.
|
||||
"""
|
||||
user_cond = ''
|
||||
if session.get_session_user_id() and user_id and user_id != str(session.get_session_user_id()):
|
||||
user_cond = 'AND session_history.user_id = %s ' % session.get_session_user_id()
|
||||
elif user_id:
|
||||
user_ids = helpers.split_strip(user_id)
|
||||
if all(id.isdigit() for id in user_ids):
|
||||
user_cond = 'AND session_history.user_id IN (%s) ' % ','.join(user_ids)
|
||||
return user_cond
|
||||
|
||||
def get_total_plays_per_dayofweek(self, time_range='30', y_axis='plays', user_id=None, grouping=None):
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -313,7 +300,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -428,7 +415,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 12
|
||||
timestamp = arrow.get(helpers.timestamp()).shift(months=-time_range).floor('month').timestamp()
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -551,7 +538,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -646,7 +633,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -752,7 +739,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -845,7 +832,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -922,7 +909,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -1025,7 +1012,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -1101,7 +1088,7 @@ class Graphs(object):
|
|||
time_range = helpers.cast_to_int(time_range) or 30
|
||||
timestamp = helpers.timestamp() - time_range * 24 * 60 * 60
|
||||
|
||||
user_cond = self.make_user_cond(user_id)
|
||||
user_cond = self._make_user_cond(user_id)
|
||||
|
||||
if grouping is None:
|
||||
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||
|
@ -1181,3 +1168,16 @@ class Graphs(object):
|
|||
'series': [series_1_output, series_2_output, series_3_output]}
|
||||
|
||||
return output
|
||||
|
||||
def _make_user_cond(self, user_id):
|
||||
"""
|
||||
Expects user_id to be a comma-separated list of ints.
|
||||
"""
|
||||
user_cond = ''
|
||||
if session.get_session_user_id() and user_id and user_id != str(session.get_session_user_id()):
|
||||
user_cond = 'AND session_history.user_id = %s ' % session.get_session_user_id()
|
||||
elif user_id:
|
||||
user_ids = helpers.split_strip(user_id)
|
||||
if all(id.isdigit() for id in user_ids):
|
||||
user_cond = 'AND session_history.user_id IN (%s) ' % ','.join(user_ids)
|
||||
return user_cond
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue