From c6548c80b3a3a34d718f523ecba2e11936691ca2 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Thu, 1 Jul 2021 16:31:50 -0700 Subject: [PATCH] Fix deleted libraries adding to watch statistics * Fixes #1456 --- plexpy/datafactory.py | 3 ++- plexpy/libraries.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index d413499d..b724153b 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -659,7 +659,8 @@ class DataFactory(object): ' FROM session_history ' \ ' WHERE session_history.stopped >= %s ' \ ' GROUP BY %s) AS sh ' \ - 'LEFT OUTER JOIN library_sections AS ls ON sh.section_id = ls.section_id ' \ + 'LEFT OUTER JOIN (SELECT * FROM library_sections WHERE deleted_section = 0) ' \ + ' AS ls ON sh.section_id = ls.section_id ' \ 'GROUP BY sh.section_id ' \ 'ORDER BY %s DESC, sh.started DESC ' \ 'LIMIT %s OFFSET %s ' % (timestamp, group_by, sort_type, stats_count, stats_start) diff --git a/plexpy/libraries.py b/plexpy/libraries.py index af66cfc7..6ec462bc 100644 --- a/plexpy/libraries.py +++ b/plexpy/libraries.py @@ -1099,7 +1099,7 @@ class Libraries(object): if row_ids and row_ids is not None: row_ids = list(map(helpers.cast_to_int, row_ids.split(','))) - # Get the user_ids corresponding to the row_ids + # Get the section_ids corresponding to the row_ids result = monitor_db.select('SELECT server_id, section_id FROM library_sections ' 'WHERE id IN ({})'.format(','.join(['?'] * len(row_ids))), row_ids)