mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Merge branch 'dev'
This commit is contained in:
commit
00c0c96b1b
13 changed files with 268 additions and 113 deletions
|
@ -1,5 +1,13 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## v1.3.16 (2016-05-01)
|
||||||
|
|
||||||
|
* Fix: Viewing photos crashing PlexPy.
|
||||||
|
* Fix: Persist Users > Edit mode on datatable page change.
|
||||||
|
* Fix: PMS update notifications broken.
|
||||||
|
* Change: Cache notifications poster with thread ID to avoid overwritting images.
|
||||||
|
|
||||||
|
|
||||||
## v1.3.15 (2016-04-18)
|
## v1.3.15 (2016-04-18)
|
||||||
|
|
||||||
* Fix: Slack notifications failing when using and icon URL.
|
* Fix: Slack notifications failing when using and icon URL.
|
||||||
|
|
42
ISSUE_TEMPLATE.md
Normal file
42
ISSUE_TEMPLATE.md
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
### Reporting Issues:
|
||||||
|
|
||||||
|
To ensure that a develpoer has enough information to work with please include all of the following information.
|
||||||
|
|
||||||
|
**Use proper markdown syntax to structure your post (i.e. code/log in code blocks).**
|
||||||
|
|
||||||
|
**Make sure you provide the following information below:**
|
||||||
|
- [ ] Version
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] Branch
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] Commit hash
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] Operating system
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] Python version
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] What you did?
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] What happened?
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] What you expected?
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] How can we reproduce your issue?
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] What are your (relevant) settings?
|
||||||
|
|
||||||
|
|
||||||
|
- [ ] Include a link to your **FULL** (not just a few lines!) log file that has the error. Please use [Gist](http://gist.github.com) or [Pastebin](http://pastebin.com/).
|
||||||
|
|
||||||
|
Close your issue when it's solved! If you found the solution yourself please comment so that others benefit from it.
|
||||||
|
|
||||||
|
#### Link to log:
|
|
@ -113,6 +113,8 @@ img {
|
||||||
}
|
}
|
||||||
.btn {
|
.btn {
|
||||||
outline:0px !important;
|
outline:0px !important;
|
||||||
|
}
|
||||||
|
.btn:not(select) {
|
||||||
-webkit-appearance:none;
|
-webkit-appearance:none;
|
||||||
}
|
}
|
||||||
.btn-dark {
|
.btn-dark {
|
||||||
|
|
|
@ -12,6 +12,14 @@
|
||||||
<span><i class="fa fa-bar-chart"></i> Graphs</span>
|
<span><i class="fa fa-bar-chart"></i> Graphs</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-bar hidden-xs">
|
<div class="button-bar hidden-xs">
|
||||||
|
<div class="btn-group" id="user-selection">
|
||||||
|
<label>
|
||||||
|
<select name="graph-user" id="graph-user" class="btn" style="color: inherit;">
|
||||||
|
<option value="">All Users</option>
|
||||||
|
<option disabled>────────────</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div class="btn-group" data-toggle="buttons" id="yaxis-selection">
|
<div class="btn-group" data-toggle="buttons" id="yaxis-selection">
|
||||||
% if config['graph_type'] == 'duration':
|
% if config['graph_type'] == 'duration':
|
||||||
<label class="btn btn-dark">
|
<label class="btn btn-dark">
|
||||||
|
@ -281,6 +289,10 @@
|
||||||
complete: function(xhr, status) {
|
complete: function(xhr, status) {
|
||||||
$('#history-modal').modal('show');
|
$('#history-modal').modal('show');
|
||||||
$("#history-modal").html(xhr.responseText);
|
$("#history-modal").html(xhr.responseText);
|
||||||
|
var opt = $('#graph-user :selected');
|
||||||
|
if (opt.prev().length) {
|
||||||
|
$('#history_table_modal_filter input[type=search]').val(opt.text()).trigger("input");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -308,8 +320,27 @@
|
||||||
var yaxis = "${config['graph_type']}";
|
var yaxis = "${config['graph_type']}";
|
||||||
var current_range = ${config['graph_days']};
|
var current_range = ${config['graph_days']};
|
||||||
var current_tab = "${'#' + config['graph_tab']}";
|
var current_tab = "${'#' + config['graph_tab']}";
|
||||||
|
var selected_user_id = undefined;
|
||||||
|
|
||||||
$('.days').html(current_range);
|
$('.days').html(current_range);
|
||||||
|
|
||||||
|
// Load user ids and names (for the selector)
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_user_names',
|
||||||
|
type: 'get',
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
var select = $('#graph-user');
|
||||||
|
data.sort(function(a, b) {
|
||||||
|
return a.friendly_name.localeCompare(b.friendly_name);
|
||||||
|
});
|
||||||
|
data.forEach(function(item) {
|
||||||
|
select.append('<option value="' + item.user_id + '">' +
|
||||||
|
item.friendly_name + '</option>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var music_visible = (${config['music_logging_enable']} == 1 ? true : false);
|
var music_visible = (${config['music_logging_enable']} == 1 ? true : false);
|
||||||
|
|
||||||
|
@ -321,7 +352,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_date",
|
url: "get_plays_by_date",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var dateArray = [];
|
var dateArray = [];
|
||||||
|
@ -348,7 +379,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_dayofweek",
|
url: "get_plays_by_dayofweek",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_dayofweek_options.xAxis.categories = data.categories;
|
hc_plays_by_dayofweek_options.xAxis.categories = data.categories;
|
||||||
|
@ -361,7 +392,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_hourofday",
|
url: "get_plays_by_hourofday",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_hourofday_options.xAxis.categories = data.categories;
|
hc_plays_by_hourofday_options.xAxis.categories = data.categories;
|
||||||
|
@ -374,7 +405,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_top_10_platforms",
|
url: "get_plays_by_top_10_platforms",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_platform_options.xAxis.categories = data.categories;
|
hc_plays_by_platform_options.xAxis.categories = data.categories;
|
||||||
|
@ -387,7 +418,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_top_10_users",
|
url: "get_plays_by_top_10_users",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_user_options.xAxis.categories = data.categories;
|
hc_plays_by_user_options.xAxis.categories = data.categories;
|
||||||
|
@ -406,7 +437,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_stream_type",
|
url: "get_plays_by_stream_type",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var dateArray = [];
|
var dateArray = [];
|
||||||
|
@ -432,7 +463,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_source_resolution",
|
url: "get_plays_by_source_resolution",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_source_resolution_options.xAxis.categories = data.categories;
|
hc_plays_by_source_resolution_options.xAxis.categories = data.categories;
|
||||||
|
@ -444,7 +475,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_by_stream_resolution",
|
url: "get_plays_by_stream_resolution",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_stream_resolution_options.xAxis.categories = data.categories;
|
hc_plays_by_stream_resolution_options.xAxis.categories = data.categories;
|
||||||
|
@ -456,7 +487,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_stream_type_by_top_10_platforms",
|
url: "get_stream_type_by_top_10_platforms",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_platform_by_stream_type_options.xAxis.categories = data.categories;
|
hc_plays_by_platform_by_stream_type_options.xAxis.categories = data.categories;
|
||||||
|
@ -468,7 +499,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_stream_type_by_top_10_users",
|
url: "get_stream_type_by_top_10_users",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { time_range: time_range, y_axis: yaxis },
|
data: { time_range: time_range, y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_user_by_stream_type_options.xAxis.categories = data.categories;
|
hc_plays_by_user_by_stream_type_options.xAxis.categories = data.categories;
|
||||||
|
@ -486,7 +517,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "get_plays_per_month",
|
url: "get_plays_per_month",
|
||||||
type: 'get',
|
type: 'get',
|
||||||
data: { y_axis: yaxis },
|
data: { y_axis: yaxis, user_id: selected_user_id },
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
hc_plays_by_month_options.yAxis.min = 0;
|
hc_plays_by_month_options.yAxis.min = 0;
|
||||||
|
@ -556,6 +587,14 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// User changed
|
||||||
|
$('#graph-user').on('change', function() {
|
||||||
|
selected_user_id = $(this).val() || undefined;
|
||||||
|
if (current_tab == '#tabs-1') { loadGraphsTab1(current_range, yaxis); }
|
||||||
|
if (current_tab == '#tabs-2') { loadGraphsTab2(current_range, yaxis); }
|
||||||
|
if (current_tab == '#tabs-3') { loadGraphsTab3(yaxis); }
|
||||||
|
});
|
||||||
|
|
||||||
// Y-axis changed
|
// Y-axis changed
|
||||||
$('#yaxis-selection').on('change', function() {
|
$('#yaxis-selection').on('change', function() {
|
||||||
yaxis = $('input[name=yaxis-options]:checked', '#yaxis-selection').val();
|
yaxis = $('input[name=yaxis-options]:checked', '#yaxis-selection').val();
|
||||||
|
@ -598,7 +637,7 @@
|
||||||
|
|
||||||
$('.yaxis-text').html('Play count');
|
$('.yaxis-text').html('Play count');
|
||||||
} else {
|
} else {
|
||||||
yaxis_format = function() { return moment.duration(this.value, 'seconds').format("m [mins]"); };
|
yaxis_format = function() { return moment.duration(this.value, 'seconds').format("H [h] m [m]"); };
|
||||||
tooltip_format = function() {
|
tooltip_format = function() {
|
||||||
if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
|
if (moment(this.x, 'X').isValid() && (this.x > 946684800)) {
|
||||||
var s = '<b>'+ moment(this.x).format("ddd MMM D") +'</b>';
|
var s = '<b>'+ moment(this.x).format("ddd MMM D") +'</b>';
|
||||||
|
|
|
@ -1,6 +1,23 @@
|
||||||
var users_to_delete = [];
|
var users_to_delete = [];
|
||||||
var users_to_purge = [];
|
var users_to_purge = [];
|
||||||
|
|
||||||
|
function toggleEditNames() {
|
||||||
|
if ($('.edit-control').hasClass('hidden')) {
|
||||||
|
$('.edit-user-control > .edit-user-name').each(function () {
|
||||||
|
a = $(this).children('a');
|
||||||
|
input = $(this).children('input');
|
||||||
|
a.text(input.val());
|
||||||
|
a.removeClass('hidden');
|
||||||
|
input.addClass('hidden');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('.edit-user-control > .edit-user-name').each(function () {
|
||||||
|
$(this).children('a').addClass('hidden');
|
||||||
|
$(this).children('input').removeClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
users_list_table_options = {
|
users_list_table_options = {
|
||||||
"language": {
|
"language": {
|
||||||
"search": "Search: ",
|
"search": "Search: ",
|
||||||
|
@ -217,6 +234,7 @@ users_list_table_options = {
|
||||||
$('.edit-control').each(function () {
|
$('.edit-control').each(function () {
|
||||||
$(this).removeClass('hidden');
|
$(this).removeClass('hidden');
|
||||||
});
|
});
|
||||||
|
toggleEditNames();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"preDrawCallback": function(settings) {
|
"preDrawCallback": function(settings) {
|
||||||
|
|
|
@ -156,14 +156,7 @@
|
||||||
$(this).addClass('hidden');
|
$(this).addClass('hidden');
|
||||||
$('#row-edit-mode-alert').fadeOut(200);
|
$('#row-edit-mode-alert').fadeOut(200);
|
||||||
});
|
});
|
||||||
$('.edit-user-control > .edit-user-name').each(function () {
|
toggleEditNames();
|
||||||
a = $(this).children('a');
|
|
||||||
input = $(this).children('input');
|
|
||||||
a.text(input.val());
|
|
||||||
a.removeClass('hidden');
|
|
||||||
input.addClass('hidden');
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
users_to_delete = [];
|
users_to_delete = [];
|
||||||
users_to_purge = [];
|
users_to_purge = [];
|
||||||
|
@ -171,10 +164,7 @@
|
||||||
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
$(this).find('button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
$(this).removeClass('hidden');
|
$(this).removeClass('hidden');
|
||||||
});
|
});
|
||||||
$('.edit-user-control > .edit-user-name').each(function () {
|
toggleEditNames();
|
||||||
$(this).children('a').addClass('hidden');
|
|
||||||
$(this).children('input').removeClass('hidden');
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
144
plexpy/graphs.py
144
plexpy/graphs.py
|
@ -24,22 +24,24 @@ class Graphs(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_total_plays_per_day(self, time_range='30', y_axis='plays'):
|
def get_total_plays_per_day(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
try:
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT date(started, "unixepoch", "localtime") AS date_played, ' \
|
query = 'SELECT date(started, "unixepoch", "localtime") AS date_played, ' \
|
||||||
'SUM(CASE WHEN media_type = "episode" THEN 1 ELSE 0 END) AS tv_count, ' \
|
'SUM(CASE WHEN media_type = "episode" THEN 1 ELSE 0 END) AS tv_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY date_played ' \
|
'GROUP BY date_played ' \
|
||||||
'ORDER BY started ASC' % time_range
|
'ORDER BY started ASC' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -51,9 +53,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY date_played ' \
|
'GROUP BY date_played ' \
|
||||||
'ORDER BY started ASC' % time_range
|
'ORDER BY started ASC' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -102,12 +104,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_per_dayofweek(self, time_range='30', y_axis='plays'):
|
def get_total_plays_per_dayofweek(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT strftime("%%w", datetime(started, "unixepoch", "localtime")) AS daynumber, ' \
|
query = 'SELECT strftime("%%w", datetime(started, "unixepoch", "localtime")) AS daynumber, ' \
|
||||||
|
@ -123,9 +127,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY dayofweek ' \
|
'GROUP BY dayofweek ' \
|
||||||
'ORDER BY daynumber' % time_range
|
'ORDER BY daynumber' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -145,9 +149,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY dayofweek ' \
|
'GROUP BY dayofweek ' \
|
||||||
'ORDER BY daynumber' % time_range
|
'ORDER BY daynumber' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -193,12 +197,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_per_hourofday(self, time_range='30', y_axis='plays'):
|
def get_total_plays_per_hourofday(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT strftime("%%H", datetime(started, "unixepoch", "localtime")) AS hourofday, ' \
|
query = 'SELECT strftime("%%H", datetime(started, "unixepoch", "localtime")) AS hourofday, ' \
|
||||||
|
@ -206,9 +212,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY hourofday ' \
|
'GROUP BY hourofday ' \
|
||||||
'ORDER BY hourofday' % time_range
|
'ORDER BY hourofday' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -220,9 +226,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \
|
'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") %s' \
|
||||||
'GROUP BY hourofday ' \
|
'GROUP BY hourofday ' \
|
||||||
'ORDER BY hourofday' % time_range
|
'ORDER BY hourofday' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -270,25 +276,27 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_per_month(self, y_axis='plays'):
|
def get_total_plays_per_month(self, y_axis='plays', user_id=None):
|
||||||
import time as time
|
import time as time
|
||||||
|
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT strftime("%Y-%m", datetime(started, "unixepoch", "localtime")) AS datestring, ' \
|
query = 'SELECT strftime("%%Y-%%m", datetime(started, "unixepoch", "localtime")) AS datestring, ' \
|
||||||
'SUM(CASE WHEN media_type = "episode" THEN 1 ELSE 0 END) AS tv_count, ' \
|
'SUM(CASE WHEN media_type = "episode" THEN 1 ELSE 0 END) AS tv_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
'SUM(CASE WHEN media_type = "movie" THEN 1 ELSE 0 END) AS movie_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(started, "unixepoch", "localtime") >= datetime("now", "-12 months", "localtime") ' \
|
'WHERE datetime(started, "unixepoch", "localtime") >= datetime("now", "-12 months", "localtime") %s' \
|
||||||
'GROUP BY strftime("%Y-%m", datetime(started, "unixepoch", "localtime")) ' \
|
'GROUP BY strftime("%%Y-%%m", datetime(started, "unixepoch", "localtime")) ' \
|
||||||
'ORDER BY datestring DESC LIMIT 12'
|
'ORDER BY datestring DESC LIMIT 12' % (user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
query = 'SELECT strftime("%Y-%m", datetime(started, "unixepoch", "localtime")) AS datestring, ' \
|
query = 'SELECT strftime("%%Y-%%m", datetime(started, "unixepoch", "localtime")) AS datestring, ' \
|
||||||
'SUM(CASE WHEN media_type = "episode" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "episode" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS tv_count, ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS tv_count, ' \
|
||||||
'SUM(CASE WHEN media_type = "movie" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "movie" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
|
@ -296,9 +304,9 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN media_type = "track" AND stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS music_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE datetime(started, "unixepoch", "localtime") >= datetime("now", "-12 months", "localtime") ' \
|
'WHERE datetime(started, "unixepoch", "localtime") >= datetime("now", "-12 months", "localtime") %s' \
|
||||||
'GROUP BY strftime("%Y-%m", datetime(started, "unixepoch", "localtime")) ' \
|
'GROUP BY strftime("%%Y-%%m", datetime(started, "unixepoch", "localtime")) ' \
|
||||||
'ORDER BY datestring DESC LIMIT 12'
|
'ORDER BY datestring DESC LIMIT 12' % (user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -351,12 +359,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_by_top_10_platforms(self, time_range='30', y_axis='plays'):
|
def get_total_plays_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT platform, ' \
|
query = 'SELECT platform, ' \
|
||||||
|
@ -365,10 +375,10 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count, ' \
|
'SUM(CASE WHEN media_type = "track" THEN 1 ELSE 0 END) AS music_count, ' \
|
||||||
'COUNT(id) AS total_count ' \
|
'COUNT(id) AS total_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) ' \
|
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) %s' \
|
||||||
'GROUP BY platform ' \
|
'GROUP BY platform ' \
|
||||||
'ORDER BY total_count DESC ' \
|
'ORDER BY total_count DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -382,10 +392,10 @@ class Graphs(object):
|
||||||
'SUM(CASE WHEN stopped > 0 THEN (stopped - started) ' \
|
'SUM(CASE WHEN stopped > 0 THEN (stopped - started) ' \
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS total_duration ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS total_duration ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) ' \
|
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) %s' \
|
||||||
'GROUP BY platform ' \
|
'GROUP BY platform ' \
|
||||||
'ORDER BY total_duration DESC ' \
|
'ORDER BY total_duration DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -414,12 +424,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_by_top_10_users(self, time_range='30', y_axis='plays'):
|
def get_total_plays_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND users.user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT ' \
|
query = 'SELECT ' \
|
||||||
|
@ -430,10 +442,10 @@ class Graphs(object):
|
||||||
'COUNT(session_history.id) AS total_count ' \
|
'COUNT(session_history.id) AS total_count ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'JOIN users ON session_history.user_id = users.user_id ' \
|
'JOIN users ON session_history.user_id = users.user_id ' \
|
||||||
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) ' \
|
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) %s' \
|
||||||
'GROUP BY session_history.user_id ' \
|
'GROUP BY session_history.user_id ' \
|
||||||
'ORDER BY total_count DESC ' \
|
'ORDER BY total_count DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -449,10 +461,10 @@ class Graphs(object):
|
||||||
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS total_duration ' \
|
' - (CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) ELSE 0 END) AS total_duration ' \
|
||||||
'FROM session_history ' \
|
'FROM session_history ' \
|
||||||
'JOIN users ON session_history.user_id = users.user_id ' \
|
'JOIN users ON session_history.user_id = users.user_id ' \
|
||||||
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) ' \
|
'WHERE (datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime")) %s' \
|
||||||
'GROUP BY session_history.user_id ' \
|
'GROUP BY session_history.user_id ' \
|
||||||
'ORDER BY total_duration DESC ' \
|
'ORDER BY total_duration DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -481,12 +493,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_per_stream_type(self, time_range='30', y_axis='plays'):
|
def get_total_plays_per_stream_type(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT date(session_history.started, "unixepoch", "localtime") AS date_played, ' \
|
query = 'SELECT date(session_history.started, "unixepoch", "localtime") AS date_played, ' \
|
||||||
|
@ -501,9 +515,9 @@ class Graphs(object):
|
||||||
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime")) AND ' \
|
'datetime("now", "-%s days", "localtime")) AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR ' \
|
||||||
'session_history.media_type = "track") ' \
|
'session_history.media_type = "track") %s' \
|
||||||
'GROUP BY date_played ' \
|
'GROUP BY date_played ' \
|
||||||
'ORDER BY started ASC' % time_range
|
'ORDER BY started ASC' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -522,9 +536,9 @@ class Graphs(object):
|
||||||
'WHERE datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime") AND ' \
|
'datetime("now", "-%s days", "localtime") AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR ' \
|
||||||
'session_history.media_type = "track") ' \
|
'session_history.media_type = "track") %s' \
|
||||||
'GROUP BY date_played ' \
|
'GROUP BY date_played ' \
|
||||||
'ORDER BY started ASC' % time_range
|
'ORDER BY started ASC' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -573,12 +587,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_by_source_resolution(self, time_range='30', y_axis='plays'):
|
def get_total_plays_by_source_resolution(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT session_history_media_info.video_resolution AS resolution, ' \
|
query = 'SELECT session_history_media_info.video_resolution AS resolution, ' \
|
||||||
|
@ -593,10 +609,10 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime")) AND ' \
|
'datetime("now", "-%s days", "localtime")) AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie") %s' \
|
||||||
'GROUP BY resolution ' \
|
'GROUP BY resolution ' \
|
||||||
'ORDER BY total_count DESC ' \
|
'ORDER BY total_count DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -616,10 +632,10 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime")) AND ' \
|
'datetime("now", "-%s days", "localtime")) AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie") %s' \
|
||||||
'GROUP BY resolution ' \
|
'GROUP BY resolution ' \
|
||||||
'ORDER BY total_duration DESC ' \
|
'ORDER BY total_duration DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -648,12 +664,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_total_plays_by_stream_resolution(self, time_range='30', y_axis='plays'):
|
def get_total_plays_by_stream_resolution(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT ' \
|
query = 'SELECT ' \
|
||||||
|
@ -678,10 +696,10 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime")) AND ' \
|
'datetime("now", "-%s days", "localtime")) AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie") %s' \
|
||||||
'GROUP BY resolution ' \
|
'GROUP BY resolution ' \
|
||||||
'ORDER BY total_count DESC ' \
|
'ORDER BY total_count DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -711,10 +729,10 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
'WHERE (datetime(session_history.stopped, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime")) AND ' \
|
'datetime("now", "-%s days", "localtime")) AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie") %s' \
|
||||||
'GROUP BY resolution ' \
|
'GROUP BY resolution ' \
|
||||||
'ORDER BY total_duration DESC ' \
|
'ORDER BY total_duration DESC ' \
|
||||||
'LIMIT 10' % time_range
|
'LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -743,12 +761,14 @@ class Graphs(object):
|
||||||
'series': [series_1_output, series_2_output, series_3_output]}
|
'series': [series_1_output, series_2_output, series_3_output]}
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays'):
|
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT session_history.platform AS platform, ' \
|
query = 'SELECT session_history.platform AS platform, ' \
|
||||||
|
@ -763,9 +783,9 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime") AND ' \
|
'datetime("now", "-%s days", "localtime") AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") %s' \
|
||||||
'GROUP BY platform ' \
|
'GROUP BY platform ' \
|
||||||
'ORDER BY total_count DESC LIMIT 10' % time_range
|
'ORDER BY total_count DESC LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -786,9 +806,9 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime") AND ' \
|
'datetime("now", "-%s days", "localtime") AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") %s' \
|
||||||
'GROUP BY platform ' \
|
'GROUP BY platform ' \
|
||||||
'ORDER BY total_duration DESC LIMIT 10' % time_range
|
'ORDER BY total_duration DESC LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -818,12 +838,14 @@ class Graphs(object):
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays'):
|
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None):
|
||||||
monitor_db = database.MonitorDatabase()
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
|
user_cond = ('AND users.user_id = %s ' % user_id) if user_id and user_id.isdigit() else ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if y_axis == 'plays':
|
if y_axis == 'plays':
|
||||||
query = 'SELECT ' \
|
query = 'SELECT ' \
|
||||||
|
@ -840,9 +862,9 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime") AND ' \
|
'datetime("now", "-%s days", "localtime") AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") %s' \
|
||||||
'GROUP BY username ' \
|
'GROUP BY username ' \
|
||||||
'ORDER BY total_count DESC LIMIT 10' % time_range
|
'ORDER BY total_count DESC LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
else:
|
else:
|
||||||
|
@ -865,9 +887,9 @@ class Graphs(object):
|
||||||
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
'JOIN session_history_media_info ON session_history.id = session_history_media_info.id ' \
|
||||||
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
'WHERE datetime(session_history.started, "unixepoch", "localtime") >= ' \
|
||||||
'datetime("now", "-%s days", "localtime") AND ' \
|
'datetime("now", "-%s days", "localtime") AND ' \
|
||||||
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") ' \
|
'(session_history.media_type = "episode" OR session_history.media_type = "movie" OR session_history.media_type = "track") %s' \
|
||||||
'GROUP BY username ' \
|
'GROUP BY username ' \
|
||||||
'ORDER BY total_duration DESC LIMIT 10' % time_range
|
'ORDER BY total_duration DESC LIMIT 10' % (time_range, user_cond)
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
result = monitor_db.select(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
import arrow
|
import arrow
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import threading
|
||||||
import time
|
import time
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
@ -622,11 +623,15 @@ def build_notify_text(session=None, timeline=None, notify_action=None, agent_id=
|
||||||
# If no previous poster_url
|
# If no previous poster_url
|
||||||
if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
|
if not poster_url and plexpy.CONFIG.NOTIFY_UPLOAD_POSTERS:
|
||||||
try:
|
try:
|
||||||
|
thread_name = str(threading.current_thread().ident)
|
||||||
# Retrieve the poster from Plex and cache to file
|
# Retrieve the poster from Plex and cache to file
|
||||||
urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN,
|
urllib.urlretrieve(plexpy.CONFIG.PMS_URL + thumb + '?X-Plex-Token=' + plexpy.CONFIG.PMS_TOKEN,
|
||||||
os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'))
|
os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-'+thread_name+'.jpg'))
|
||||||
# Upload thumb to Imgur and get link
|
# Upload thumb to Imgur and get link
|
||||||
poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster.jpg'), poster_title)
|
poster_url = helpers.uploadToImgur(os.path.join(plexpy.CONFIG.CACHE_DIR,
|
||||||
|
'cache-poster-'+thread_name+'.jpg'), poster_title)
|
||||||
|
# Delete the cached poster
|
||||||
|
os.remove(os.path.join(plexpy.CONFIG.CACHE_DIR, 'cache-poster-'+thread_name+'.jpg'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(u"PlexPy Notifier :: Unable to retrieve poster for rating_key %s: %s." % (str(rating_key), e))
|
logger.error(u"PlexPy Notifier :: Unable to retrieve poster for rating_key %s: %s." % (str(rating_key), e))
|
||||||
|
|
||||||
|
@ -929,6 +934,7 @@ def build_server_notify_text(notify_action=None, agent_id=None):
|
||||||
|
|
||||||
update_status = {}
|
update_status = {}
|
||||||
if notify_action == 'pmsupdate':
|
if notify_action == 'pmsupdate':
|
||||||
|
pms_connect = pmsconnect.PmsConnect()
|
||||||
update_status = pms_connect.get_update_staus()
|
update_status = pms_connect.get_update_staus()
|
||||||
|
|
||||||
if server_times:
|
if server_times:
|
||||||
|
@ -1103,4 +1109,4 @@ def strip_tag(data, agent_id=None):
|
||||||
else:
|
else:
|
||||||
p = re.compile(r'<.*?>', re.IGNORECASE | re.DOTALL)
|
p = re.compile(r'<.*?>', re.IGNORECASE | re.DOTALL)
|
||||||
|
|
||||||
return p.sub('', data)
|
return p.sub('', data)
|
||||||
|
|
|
@ -1348,6 +1348,7 @@ class PmsConnect(object):
|
||||||
transcode_container = helpers.get_xml_attr(transcode_session, 'container')
|
transcode_container = helpers.get_xml_attr(transcode_session, 'container')
|
||||||
transcode_protocol = helpers.get_xml_attr(transcode_session, 'protocol')
|
transcode_protocol = helpers.get_xml_attr(transcode_session, 'protocol')
|
||||||
else:
|
else:
|
||||||
|
transcode_key = ''
|
||||||
throttled = '0'
|
throttled = '0'
|
||||||
transcode_progress = '0'
|
transcode_progress = '0'
|
||||||
transcode_speed = ''
|
transcode_speed = ''
|
||||||
|
|
|
@ -21,6 +21,23 @@ class Users(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_user_names(self, kwargs=None):
|
||||||
|
monitor_db = database.MonitorDatabase()
|
||||||
|
|
||||||
|
try:
|
||||||
|
query = 'SELECT user_id, ' \
|
||||||
|
'(CASE WHEN users.friendly_name IS NULL OR TRIM(users.friendly_name) = "" \
|
||||||
|
THEN users.username ELSE users.friendly_name END) AS friendly_name ' \
|
||||||
|
'FROM users ' \
|
||||||
|
'WHERE deleted_user = 0'
|
||||||
|
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn(u"PlexPy Graphs :: Unable to execute database query for get_user_names: %s." % e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
def get_datatables_list(self, kwargs=None):
|
def get_datatables_list(self, kwargs=None):
|
||||||
data_tables = datatables.DataTables()
|
data_tables = datatables.DataTables()
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
PLEXPY_VERSION = "master"
|
PLEXPY_VERSION = "master"
|
||||||
PLEXPY_RELEASE_VERSION = "1.3.15"
|
PLEXPY_RELEASE_VERSION = "1.3.16"
|
||||||
|
|
|
@ -106,7 +106,7 @@ def run():
|
||||||
ws.shutdown()
|
ws.shutdown()
|
||||||
ws_connected = False
|
ws_connected = False
|
||||||
start_thread()
|
start_thread()
|
||||||
|
|
||||||
if not ws_connected and not ws_reconnect:
|
if not ws_connected and not ws_reconnect:
|
||||||
logger.error(u"PlexPy WebSocket :: Connection unavailable, falling back to polling.")
|
logger.error(u"PlexPy WebSocket :: Connection unavailable, falling back to polling.")
|
||||||
plexpy.POLLING_FAILOVER = True
|
plexpy.POLLING_FAILOVER = True
|
||||||
|
|
|
@ -861,13 +861,23 @@ class WebInterface(object):
|
||||||
plexpy.CONFIG.write()
|
plexpy.CONFIG.write()
|
||||||
|
|
||||||
return "Updated graphs config values."
|
return "Updated graphs config values."
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_date(self, time_range='30', y_axis='plays', **kwargs):
|
def get_user_names(self, **kwargs):
|
||||||
|
|
||||||
|
user_data = users.Users()
|
||||||
|
user_names = user_data.get_user_names(kwargs=kwargs)
|
||||||
|
|
||||||
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
return json.dumps(user_names)
|
||||||
|
|
||||||
|
@cherrypy.expose
|
||||||
|
@addtoapi()
|
||||||
|
def get_plays_by_date(self, time_range='30', user_id=None, y_axis='plays', **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_per_day(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_per_day(time_range=time_range, user_id=user_id, y_axis=y_axis)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -877,10 +887,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_dayofweek(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_dayofweek(self, time_range='30', user_id=None, y_axis='plays', **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_per_dayofweek(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_per_dayofweek(time_range=time_range, user_id=user_id, y_axis=y_axis)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -890,10 +900,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_hourofday(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_hourofday(self, time_range='30', user_id=None, y_axis='plays', **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_per_hourofday(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_per_hourofday(time_range=time_range, user_id=user_id, y_axis=y_axis)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -903,10 +913,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_per_month(self, y_axis='plays', **kwargs):
|
def get_plays_per_month(self, y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_per_month(y_axis=y_axis)
|
result = graph.get_total_plays_per_month(y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -916,10 +926,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_top_10_platforms(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_by_top_10_platforms(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_by_top_10_platforms(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -929,10 +939,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_top_10_users(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_by_top_10_users(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_by_top_10_users(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -942,10 +952,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_stream_type(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_stream_type(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_per_stream_type(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_per_stream_type(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -955,10 +965,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_source_resolution(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_source_resolution(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_by_source_resolution(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_by_source_resolution(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -968,10 +978,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_plays_by_stream_resolution(self, time_range='30', y_axis='plays', **kwargs):
|
def get_plays_by_stream_resolution(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_total_plays_by_stream_resolution(time_range=time_range, y_axis=y_axis)
|
result = graph.get_total_plays_by_stream_resolution(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -981,10 +991,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays', **kwargs):
|
def get_stream_type_by_top_10_users(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_stream_type_by_top_10_users(time_range=time_range, y_axis=y_axis)
|
result = graph.get_stream_type_by_top_10_users(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
@ -994,10 +1004,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
@addtoapi()
|
@addtoapi()
|
||||||
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', **kwargs):
|
def get_stream_type_by_top_10_platforms(self, time_range='30', y_axis='plays', user_id=None, **kwargs):
|
||||||
|
|
||||||
graph = graphs.Graphs()
|
graph = graphs.Graphs()
|
||||||
result = graph.get_stream_type_by_top_10_platforms(time_range=time_range, y_axis=y_axis)
|
result = graph.get_stream_type_by_top_10_platforms(time_range=time_range, y_axis=y_axis, user_id=user_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue