Allow custom time_queries for get_watch_stats

This commit is contained in:
Mitch 2020-04-05 20:03:57 +02:00
parent 16ffbd9940
commit d1f1763919
4 changed files with 21 additions and 8 deletions

View file

@ -812,16 +812,20 @@ class Libraries(object):
# If there is no library data we must return something
return default_return
def get_watch_time_stats(self, section_id=None, grouping=None):
def get_watch_time_stats(self, section_id=None, grouping=None, time_queries=None):
if not session.allow_session_library(section_id):
return []
if grouping is None:
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
if time_queries is not None:
time_queries = map(int, time_queries.split(","))
else:
time_queries = [1, 7, 30, 0]
monitor_db = database.MonitorDatabase()
time_queries = [1, 7, 30, 0]
library_watch_time_stats = []
group_by = 'session_history.reference_id' if grouping else 'session_history.id'