From b552143b2aee5c4be78126257dfe1842d1bba953 Mon Sep 17 00:00:00 2001 From: herby2212 <12448284+herby2212@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:50:04 +0200 Subject: [PATCH] max concurrent streams in graph --- data/interfaces/default/graphs.html | 1 - .../graphs/concurrent_streams_by_stream_type.js | 15 ++++++++++++++- plexpy/graphs.py | 16 +++++++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/data/interfaces/default/graphs.html b/data/interfaces/default/graphs.html index 796cfc31..52a4e0d6 100644 --- a/data/interfaces/default/graphs.html +++ b/data/interfaces/default/graphs.html @@ -816,7 +816,6 @@ hc_plays_by_platform_options.tooltip.formatter = tooltip_format; hc_plays_by_user_options.tooltip.formatter = tooltip_format; hc_plays_by_stream_type_options.tooltip.formatter = tooltip_format; - hc_concurrent_streams_by_stream_type_options.tooltip.formatter = tooltip_format; hc_plays_by_source_resolution_options.tooltip.formatter = tooltip_format; hc_plays_by_stream_resolution_options.tooltip.formatter = tooltip_format; hc_plays_by_platform_by_stream_type_options.tooltip.formatter = tooltip_format; diff --git a/data/interfaces/default/js/graphs/concurrent_streams_by_stream_type.js b/data/interfaces/default/js/graphs/concurrent_streams_by_stream_type.js index 8bbf97ca..623e4735 100644 --- a/data/interfaces/default/js/graphs/concurrent_streams_by_stream_type.js +++ b/data/interfaces/default/js/graphs/concurrent_streams_by_stream_type.js @@ -1,3 +1,15 @@ +var formatter_function = function() { + if (moment(this.x, 'X').isValid() && (this.x > 946684800)) { + var s = ''+ moment(this.x).format('ddd MMM D') +''; + } else { + var s = ''+ this.x +''; + } + $.each(this.points, function(i, point) { + s += '
'+point.series.name+': '+point.y; + }); + return s; +}; + var hc_concurrent_streams_by_stream_type_options = { chart: { type: 'line', @@ -57,7 +69,8 @@ var hc_concurrent_streams_by_stream_type_options = { }, tooltip: { shared: true, - crosshairs: true + crosshairs: true, + formatter: formatter_function }, series: [{}] }; \ No newline at end of file diff --git a/plexpy/graphs.py b/plexpy/graphs.py index 62ea1efd..3dbf6102 100644 --- a/plexpy/graphs.py +++ b/plexpy/graphs.py @@ -879,8 +879,10 @@ class Graphs(object): series_1 = [] series_2 = [] series_3 = [] + series_4 = [] - grouped_result = helpers.group_by_keys(result, ('date_played','transcode_decision')) + grouped_result_by_stream_type = helpers.group_by_keys(result, ('date_played','transcode_decision')) + grouped_result_by_day = helpers.group_by_keys(result, ['date_played']) for date_item in sorted(date_list): date_string = date_item.strftime('%Y-%m-%d') @@ -888,18 +890,24 @@ class Graphs(object): series_1_value = 0 series_2_value = 0 series_3_value = 0 + series_4_value = 0 - for item in grouped_result: + for item in grouped_result_by_stream_type: if item['key'] == (date_string,'direct play'): series_1_value = calc_most_concurrent(item['value']) elif item['key'] == (date_string,'copy'): series_2_value = calc_most_concurrent(item['value']) elif item['key'] == (date_string,'transcode'): series_3_value = calc_most_concurrent(item['value']) + + for item in grouped_result_by_day: + if item['key'] == date_string: + series_4_value = calc_most_concurrent(item['value']) series_1.append(series_1_value) series_2.append(series_2_value) series_3.append(series_3_value) + series_4.append(series_4_value) series_1_output = {'name': 'Direct Play', 'data': series_1} @@ -907,9 +915,11 @@ class Graphs(object): 'data': series_2} series_3_output = {'name': 'Transcode', 'data': series_3} + series_4_output = {'name': 'Max. Concurrent Streams', + 'data': series_4} output = {'categories': categories, - 'series': [series_1_output, series_2_output, series_3_output]} + 'series': [series_1_output, series_2_output, series_3_output, series_4_output]} return output def get_total_plays_by_source_resolution(self, time_range='30', y_axis='plays', user_id=None, grouping=None):