From 9b7b8af8a83bb1bb6b9132e9bf3cf1381a6b918e Mon Sep 17 00:00:00 2001 From: Tom Niget Date: Wed, 21 Jun 2023 17:13:14 +0200 Subject: [PATCH] Extend make_user_cond to allow lists of user IDs --- plexpy/graphs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plexpy/graphs.py b/plexpy/graphs.py index 48c56369..784fa008 100644 --- a/plexpy/graphs.py +++ b/plexpy/graphs.py @@ -162,11 +162,16 @@ class Graphs(object): 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 and user_id.isdigit(): - user_cond = 'AND session_history.user_id = %s ' % user_id + elif user_id: + user_ids = [id.strip() for id in user_id.split(',')] + 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):