mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Merge pull request #190 from JonnyWong16/group-history
Group history on tables
This commit is contained in:
commit
3320f2a2f9
9 changed files with 471 additions and 90 deletions
|
@ -2416,7 +2416,41 @@ a .home-platforms-instance-list-oval:hover,
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
table.display tr.shown + tr div.slider {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr > td {
|
||||||
|
padding-top: 0;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr:hover {
|
||||||
|
background-color: rgba(255,255,255,0);
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr:hover a,
|
||||||
|
table.display tr.shown + tr td:hover a,
|
||||||
|
table.display tr.shown + tr .pagination > .active > a,
|
||||||
|
table.display tr.shown + tr .pagination > .active > a:hover {
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr table[id^='history_child'] td:hover a {
|
||||||
|
color: #F9AA03;
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr .pagination > .disabled > a {
|
||||||
|
color: #444444;
|
||||||
|
}
|
||||||
|
table.display tr.shown + tr .pagination > li > a:hover {
|
||||||
|
color: #23527c;
|
||||||
|
}
|
||||||
|
table[id^='history_child'] {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-left: -4px;
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
table[id^='history_child'] thead th {
|
||||||
|
line-height: 0;
|
||||||
|
height: 0 !important;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
#search_form {
|
#search_form {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
padding: 8px 15px;
|
padding: 8px 15px;
|
||||||
|
|
|
@ -46,13 +46,18 @@ history_table_options = {
|
||||||
"createdCell": function (td, cellData, rowData, row, col) {
|
"createdCell": function (td, cellData, rowData, row, col) {
|
||||||
if (rowData['stopped'] === null) {
|
if (rowData['stopped'] === null) {
|
||||||
$(td).html('Currently watching...');
|
$(td).html('Currently watching...');
|
||||||
|
} else if (rowData['group_count'] > 1) {
|
||||||
|
date = moment(cellData, "X").format(date_format);
|
||||||
|
expand_history = '<span class="expand-history-tooltip" data-toggle="tooltip" title="Show Detailed History"><i class="fa fa-plus-circle fa-fw"></i></span>';
|
||||||
|
$(td).html('<div><a href="#"><div style="float: left;">' + expand_history + ' ' + date + '</div></a></div>');
|
||||||
} else {
|
} else {
|
||||||
$(td).html(moment(cellData,"X").format(date_format));
|
date = moment(cellData, "X").format(date_format);
|
||||||
|
$(td).html('<div style="float: left;"><i class="fa fa-fw"></i> ' + date + '</div>');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"searchable": false,
|
"searchable": false,
|
||||||
"width": "8%",
|
"width": "8%",
|
||||||
"className": "no-wrap"
|
"className": "no-wrap expand-history"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [2],
|
"targets": [2],
|
||||||
|
@ -83,7 +88,8 @@ history_table_options = {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal"><i class="fa fa-map-marker"></i> ' + cellData + '</a>');
|
external_ip = '<span class="external-ip-tooltip" data-toggle="tooltip" title="External IP"><i class="fa fa-map-marker fa-fw"></i></span>';
|
||||||
|
$(td).html('<a href="javascript:void(0)" data-toggle="modal" data-target="#ip-info-modal">'+ external_ip + cellData + '</a>');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(td).html('n/a');
|
$(td).html('n/a');
|
||||||
|
@ -105,7 +111,7 @@ history_table_options = {
|
||||||
} else if (rowData['video_decision'] === 'direct play' || rowData['audio_decision'] === 'direct play') {
|
} else if (rowData['video_decision'] === 'direct play' || rowData['audio_decision'] === 'direct play') {
|
||||||
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Direct Play"><i class="fa fa-play-circle fa-fw"></i></span>';
|
transcode_dec = '<span class="transcode-tooltip" data-toggle="tooltip" title="Direct Play"><i class="fa fa-play-circle fa-fw"></i></span>';
|
||||||
}
|
}
|
||||||
$(td).html('<div><a href="#" data-target="#info-modal" data-toggle="modal"><div style="float: left;">' + transcode_dec + ' ' + cellData + '</div></a></div>');
|
$(td).html('<div><a href="#" data-target="#info-modal" data-toggle="modal"><div style="float: left;">' + transcode_dec + ' ' + cellData + '</div></a></div>');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"width": "15%",
|
"width": "15%",
|
||||||
|
@ -121,16 +127,16 @@ history_table_options = {
|
||||||
if (rowData['media_type'] === 'movie') {
|
if (rowData['media_type'] === 'movie') {
|
||||||
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Movie"><i class="fa fa-film fa-fw"></i></span>';
|
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Movie"><i class="fa fa-film fa-fw"></i></span>';
|
||||||
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120">' + cellData + ' (' + rowData['year'] + ')</span>'
|
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120">' + cellData + ' (' + rowData['year'] + ')</span>'
|
||||||
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
||||||
} else if (rowData['media_type'] === 'episode') {
|
} else if (rowData['media_type'] === 'episode') {
|
||||||
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Episode"><i class="fa fa-television fa-fw"></i></span>';
|
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Episode"><i class="fa fa-television fa-fw"></i></span>';
|
||||||
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120">' + cellData + ' \
|
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=450&fallback=poster" data-height="120">' + cellData + ' \
|
||||||
(S' + rowData['parent_media_index'] + '· E' + rowData['media_index'] + ')</span>'
|
(S' + rowData['parent_media_index'] + '· E' + rowData['media_index'] + ')</span>'
|
||||||
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;" >' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;" >' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
||||||
} else if (rowData['media_type'] === 'track') {
|
} else if (rowData['media_type'] === 'track') {
|
||||||
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Track"><i class="fa fa-music fa-fw"></i></span>';
|
media_type = '<span class="media-type-tooltip" data-toggle="tooltip" title="Track"><i class="fa fa-music fa-fw"></i></span>';
|
||||||
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=300&fallback=poster" data-height="80">' + cellData + ' (' + rowData['parent_title'] + ')</span>'
|
thumb_popover = '<span class="thumb-tooltip" data-toggle="popover" data-img="pms_image_proxy?img=' + rowData['thumb'] + '&width=300&height=300&fallback=poster" data-height="80">' + cellData + ' (' + rowData['parent_title'] + ')</span>'
|
||||||
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
$(td).html('<div class="history-title"><a href="info?source=history&item_id=' + rowData['id'] + '"><div style="float: left;">' + media_type + ' ' + thumb_popover + '</div></a></div>');
|
||||||
} else {
|
} else {
|
||||||
$(td).html('<a href="info?item_id=' + rowData['id'] + '">' + cellData + '</a>');
|
$(td).html('<a href="info?item_id=' + rowData['id'] + '">' + cellData + '</a>');
|
||||||
}
|
}
|
||||||
|
@ -196,11 +202,11 @@ history_table_options = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"targets": [10],
|
"targets": [10],
|
||||||
"data":"percent_complete",
|
"data": "watched_status",
|
||||||
"render": function (data, type, full) {
|
"render": function (data, type, full) {
|
||||||
if (data > 80) {
|
if (data == 1) {
|
||||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Watched"><i class="fa fa-lg fa-circle"></i></span>'
|
return '<span class="watched-tooltip" data-toggle="tooltip" title="Watched"><i class="fa fa-lg fa-circle"></i></span>'
|
||||||
} else if (data > 40) {
|
} else if (data == 0.5) {
|
||||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Partial"><i class="fa fa-lg fa-adjust fa-rotate-180"></i></span>'
|
return '<span class="watched-tooltip" data-toggle="tooltip" title="Partial"><i class="fa fa-lg fa-adjust fa-rotate-180"></i></span>'
|
||||||
} else {
|
} else {
|
||||||
return '<span class="watched-tooltip" data-toggle="tooltip" title="Unwatched"><i class="fa fa-lg fa-circle-o"></i></span>'
|
return '<span class="watched-tooltip" data-toggle="tooltip" title="Unwatched"><i class="fa fa-lg fa-circle-o"></i></span>'
|
||||||
|
@ -218,6 +224,8 @@ history_table_options = {
|
||||||
$('#ajaxMsg').fadeOut();
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
// Create the tooltips.
|
// Create the tooltips.
|
||||||
|
$('.expand-history-tooltip').tooltip({ container: 'body' });
|
||||||
|
$('.external-ip-tooltip').tooltip();
|
||||||
$('.transcode-tooltip').tooltip();
|
$('.transcode-tooltip').tooltip();
|
||||||
$('.media-type-tooltip').tooltip();
|
$('.media-type-tooltip').tooltip();
|
||||||
$('.watched-tooltip').tooltip();
|
$('.watched-tooltip').tooltip();
|
||||||
|
@ -235,20 +243,53 @@ history_table_options = {
|
||||||
$(this).removeClass('hidden');
|
$(this).removeClass('hidden');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
history_table.rows().every(function () {
|
||||||
|
var rowData = this.data();
|
||||||
|
if (rowData['group_count'] != 1 && rowData['reference_id'] in history_child_table) {
|
||||||
|
// if grouped row and a child table was already created
|
||||||
|
$(this.node()).find('i.fa').toggleClass('fa-plus-circle').toggleClass('fa-minus-circle');
|
||||||
|
this.child(childTableFormat(rowData)).show();
|
||||||
|
createChildTable(this, rowData)
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
"preDrawCallback": function(settings) {
|
"preDrawCallback": function(settings) {
|
||||||
var msg = "<i class='fa fa-refresh fa-spin'></i> Fetching rows...";
|
var msg = "<i class='fa fa-refresh fa-spin'></i> Fetching rows...";
|
||||||
showMsg(msg, false, false, 0)
|
showMsg(msg, false, false, 0)
|
||||||
},
|
},
|
||||||
"rowCallback": function (row, rowData) {
|
"rowCallback": function (row, rowData, rowIndex) {
|
||||||
|
if (rowData['group_count'] == 1) {
|
||||||
|
// if no grouped rows simply toggle the delete button
|
||||||
if ($.inArray(rowData['id'], history_to_delete) !== -1) {
|
if ($.inArray(rowData['id'], history_to_delete) !== -1) {
|
||||||
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
|
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// if grouped rows
|
||||||
|
// toggle the parent button to danger
|
||||||
|
$(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
// check if any child rows are not selected
|
||||||
|
var group_ids = rowData['group_ids'].split(',').map(Number);
|
||||||
|
group_ids.forEach(function (id) {
|
||||||
|
var index = $.inArray(id, history_to_delete);
|
||||||
|
if (index == -1) {
|
||||||
|
$(row).find('button[data-id="' + rowData['id'] + '"]').addClass('btn-warning').removeClass('btn-danger');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rowData['group_count'] != 1 && rowData['reference_id'] in history_child_table) {
|
||||||
|
// if grouped row and a child table was already created
|
||||||
|
$(row).addClass('shown')
|
||||||
|
history_table.row(row).child(childTableFormat(rowData)).show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#history_table').on('click', 'td.modal-control', function () {
|
// Parent table platform modal
|
||||||
var tr = $(this).parents('tr');
|
$('#history_table').on('click', '> tbody > tr > td.modal-control', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
|
@ -266,8 +307,9 @@ $('#history_table').on('click', 'td.modal-control', function () {
|
||||||
showStreamDetails();
|
showStreamDetails();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#history_table').on('click', 'td.modal-control-ip', function () {
|
// Parent table ip address modal
|
||||||
var tr = $(this).parents('tr');
|
$('#history_table').on('click', '> tbody > tr > td.modal-control-ip', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
|
@ -288,11 +330,14 @@ $('#history_table').on('click', 'td.modal-control-ip', function () {
|
||||||
getUserLocation(rowData['ip_address']);
|
getUserLocation(rowData['ip_address']);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#history_table').on('click', 'td.delete-control > button', function () {
|
// Parent table delete mode
|
||||||
var tr = $(this).parents('tr');
|
$('#history_table').on('click', '> tbody > tr > td.delete-control > button', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
var row = history_table.row( tr );
|
var row = history_table.row( tr );
|
||||||
var rowData = row.data();
|
var rowData = row.data();
|
||||||
|
|
||||||
|
if (rowData['group_count'] == 1) {
|
||||||
|
// if no grouped rows simply add or remove row from history_to_delete
|
||||||
var index = $.inArray(rowData['id'], history_to_delete);
|
var index = $.inArray(rowData['id'], history_to_delete);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
history_to_delete.push(rowData['id']);
|
history_to_delete.push(rowData['id']);
|
||||||
|
@ -300,4 +345,223 @@ $('#history_table').on('click', 'td.delete-control > button', function () {
|
||||||
history_to_delete.splice(index, 1);
|
history_to_delete.splice(index, 1);
|
||||||
}
|
}
|
||||||
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
} else {
|
||||||
|
// if grouped rows
|
||||||
|
if ($(this).hasClass('btn-warning')) {
|
||||||
|
// add all grouped rows to history_to_delete
|
||||||
|
var group_ids = rowData['group_ids'].split(',').map(Number);
|
||||||
|
group_ids.forEach(function (id) {
|
||||||
|
var index = $.inArray(id, history_to_delete);
|
||||||
|
if (index == -1) {
|
||||||
|
history_to_delete.push(id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
if (row.child.isShown()) {
|
||||||
|
// if child table is visible, toggle all child buttons to danger
|
||||||
|
tr.next().find('td.delete-control > button.btn-warning').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// remove all grouped rows to history_to_delete
|
||||||
|
var group_ids = rowData['group_ids'].split(',').map(Number);
|
||||||
|
group_ids.forEach(function (id) {
|
||||||
|
var index = $.inArray(id, history_to_delete);
|
||||||
|
if (index != -1) {
|
||||||
|
history_to_delete.splice(index, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
if (row.child.isShown()) {
|
||||||
|
// if child table is visible, toggle all child buttons to warning
|
||||||
|
tr.next().find('td.delete-control > button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Parent table expand detailed history
|
||||||
|
$('#history_table').on('click', '> tbody > tr > td.expand-history a', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
|
var row = history_table.row(tr);
|
||||||
|
var rowData = row.data();
|
||||||
|
|
||||||
|
$(this).find('i.fa').toggleClass('fa-plus-circle').toggleClass('fa-minus-circle');
|
||||||
|
|
||||||
|
if (row.child.isShown()) {
|
||||||
|
$('div.slider', row.child()).slideUp(function () {
|
||||||
|
row.child.hide();
|
||||||
|
tr.removeClass('shown');
|
||||||
|
delete history_child_table[rowData['reference_id']];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tr.addClass('shown');
|
||||||
|
row.child(childTableFormat(rowData)).show();
|
||||||
|
createChildTable(row, rowData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize the detailed history child table options using the parent table options
|
||||||
|
function childTableOptions(rowData) {
|
||||||
|
history_child_options = history_table_options;
|
||||||
|
// Remove settings that are not necessary
|
||||||
|
history_child_options.searching = false;
|
||||||
|
history_child_options.lengthChange = false;
|
||||||
|
history_child_options.info = false;
|
||||||
|
history_child_options.pageLength = 10;
|
||||||
|
history_child_options.bStateSave = false;
|
||||||
|
history_child_options.ajax = {
|
||||||
|
"url": "get_history",
|
||||||
|
type: "post",
|
||||||
|
data: function (d) {
|
||||||
|
return {
|
||||||
|
'json_data': JSON.stringify(d),
|
||||||
|
'grouping': false,
|
||||||
|
'reference_id': rowData['reference_id']
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
history_child_options.fnDrawCallback = function (settings) {
|
||||||
|
$('#ajaxMsg').fadeOut();
|
||||||
|
|
||||||
|
// Create the tooltips.
|
||||||
|
$('.expand-history-tooltip').tooltip({ container: 'body' });
|
||||||
|
$('.external-ip-tooltip').tooltip();
|
||||||
|
$('.transcode-tooltip').tooltip();
|
||||||
|
$('.media-type-tooltip').tooltip();
|
||||||
|
$('.watched-tooltip').tooltip();
|
||||||
|
$('.thumb-tooltip').popover({
|
||||||
|
html: true,
|
||||||
|
trigger: 'hover',
|
||||||
|
placement: 'right',
|
||||||
|
content: function () {
|
||||||
|
return '<div class="history-thumbnail" style="background-image: url(' + $(this).data('img') + '); height: ' + $(this).data('height') + 'px;" />';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($('#row-edit-mode').hasClass('active')) {
|
||||||
|
$('.delete-control').each(function () {
|
||||||
|
$(this).removeClass('hidden');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(this).closest('div.slider').slideDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
return history_child_options;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the detailed history child table
|
||||||
|
function childTableFormat(rowData) {
|
||||||
|
return '<div class="slider">' +
|
||||||
|
'<table id="history_child-' + rowData['reference_id'] + '">' +
|
||||||
|
'<thead>' +
|
||||||
|
'<tr>' +
|
||||||
|
'<th align="left" id="delete_row">Delete</th>' +
|
||||||
|
'<th align="left" id="time">Time</th>' +
|
||||||
|
'<th align="left" id="friendly_name">User</th>' +
|
||||||
|
'<th align="left" id="ip_address">IP Address</th>' +
|
||||||
|
'<th align="left" id="platform">Platform</th>' +
|
||||||
|
'<th align="left" id="title">Title</th>' +
|
||||||
|
'<th align="left" id="started">Started</th>' +
|
||||||
|
'<th align="left" id="paused_counter">Paused</th>' +
|
||||||
|
'<th align="left" id="stopped">Stopped</th>' +
|
||||||
|
'<th align="left" id="duration">Duration</th>' +
|
||||||
|
'<th align="left" id="percent_complete"></th>' +
|
||||||
|
'</tr>' +
|
||||||
|
'</thead>' +
|
||||||
|
'<tbody>' +
|
||||||
|
'</tbody>' +
|
||||||
|
'</table>' +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the detailed history child table
|
||||||
|
history_child_table = {};
|
||||||
|
function createChildTable(row, rowData) {
|
||||||
|
history_child_options = childTableOptions(rowData);
|
||||||
|
// initialize the child table
|
||||||
|
history_child_table[rowData['reference_id']] = $('#history_child-' + rowData['reference_id']).DataTable(history_child_options);
|
||||||
|
|
||||||
|
// Set child table column visibility to match parent table
|
||||||
|
var visibility = history_table.columns().visible();
|
||||||
|
for (var i = 0; i < visibility.length; i++) {
|
||||||
|
if (!(visibility[i])) { history_child_table[rowData['reference_id']].column(i).visible(visibility[i]); }
|
||||||
|
}
|
||||||
|
history_table.on('column-visibility', function (e, settings, colIdx, visibility) {
|
||||||
|
if (row.child.isShown()) {
|
||||||
|
history_child_table[rowData['reference_id']].column(colIdx).visible(visibility);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Child table platform modal
|
||||||
|
$('#history_child-' + rowData['reference_id']).on('click', 'td.modal-control', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
|
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
||||||
|
var childRowData = childRow.data();
|
||||||
|
|
||||||
|
function showStreamDetails() {
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_stream_data',
|
||||||
|
data: { row_id: childRowData['id'], user: childRowData['friendly_name'] },
|
||||||
|
cache: false,
|
||||||
|
async: true,
|
||||||
|
complete: function (xhr, status) {
|
||||||
|
$("#info-modal").html(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
showStreamDetails();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Child table ip address modal
|
||||||
|
$('#history_child-' + rowData['reference_id']).on('click', 'td.modal-control-ip', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
|
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
||||||
|
var childRowData = childRow.data();
|
||||||
|
|
||||||
|
function getUserLocation(ip_address) {
|
||||||
|
if (isPrivateIP(ip_address)) {
|
||||||
|
return "n/a"
|
||||||
|
} else {
|
||||||
|
$.ajax({
|
||||||
|
url: 'get_ip_address_details',
|
||||||
|
data: { ip_address: ip_address },
|
||||||
|
async: true,
|
||||||
|
complete: function (xhr, status) {
|
||||||
|
$("#ip-info-modal").html(xhr.responseText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getUserLocation(childRowData['ip_address']);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Child table delete mode
|
||||||
|
$('#history_child-' + rowData['reference_id']).on('click', 'td.delete-control > button', function () {
|
||||||
|
var tr = $(this).closest('tr');
|
||||||
|
var childRow = history_child_table[rowData['reference_id']].row(tr);
|
||||||
|
var childRowData = childRow.data();
|
||||||
|
|
||||||
|
// add or remove row from history_to_delete
|
||||||
|
var index = $.inArray(childRowData['id'], history_to_delete);
|
||||||
|
if (index === -1) {
|
||||||
|
history_to_delete.push(childRowData['id']);
|
||||||
|
} else {
|
||||||
|
history_to_delete.splice(index, 1);
|
||||||
|
}
|
||||||
|
$(this).toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
|
||||||
|
tr.parents('tr').prev().find('td.delete-control > button.btn-warning').toggleClass('btn-warning').toggleClass('btn-danger');
|
||||||
|
// check if any child rows are not selected
|
||||||
|
var group_ids = rowData['group_ids'].split(',').map(Number);
|
||||||
|
group_ids.forEach(function (id) {
|
||||||
|
var index = $.inArray(id, history_to_delete);
|
||||||
|
if (index == -1) {
|
||||||
|
// if any child row is not selected, toggle parent button to warning
|
||||||
|
tr.parents('tr').prev().find('td.delete-control > button.btn-danger').addClass('btn-warning').removeClass('btn-danger');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,7 @@ history_table_modal_options = {
|
||||||
$('.media-type-tooltip').tooltip();
|
$('.media-type-tooltip').tooltip();
|
||||||
$('.thumb-tooltip').popover({
|
$('.thumb-tooltip').popover({
|
||||||
html: true,
|
html: true,
|
||||||
|
container: '#history-modal',
|
||||||
trigger: 'hover',
|
trigger: 'hover',
|
||||||
placement: 'right',
|
placement: 'right',
|
||||||
content: function () {
|
content: function () {
|
||||||
|
|
|
@ -84,6 +84,12 @@ available_notification_agents = notifiers.available_notification_agents()
|
||||||
</div>
|
</div>
|
||||||
<p class="help-block">Set your preferred time format. <a href="javascript:void(0)" data-target="#dateTimeOptionsModal" data-toggle="modal">Click here</a> to see the parameter list.</p>
|
<p class="help-block">Set your preferred time format. <a href="javascript:void(0)" data-target="#dateTimeOptionsModal" data-toggle="modal">Click here</a> to see the parameter list.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" id="group_history_tables" name="group_history_tables" value="1" ${config['group_history_tables']}> Group Table History
|
||||||
|
</label>
|
||||||
|
<p class="help-block">Group successive play history by the same user as a single entry in tables.</p>
|
||||||
|
</div>
|
||||||
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
|
<p><input type="button" class="btn btn-bright save-button" value="Save" data-success="Changes saved successfully"></p>
|
||||||
</div>
|
</div>
|
||||||
<div role="tabpanel" class="tab-pane" id="tabs-2">
|
<div role="tabpanel" class="tab-pane" id="tabs-2">
|
||||||
|
|
|
@ -366,7 +366,7 @@ def dbcheck():
|
||||||
|
|
||||||
# session_history table :: This is a history table which logs essential stream details
|
# session_history table :: This is a history table which logs essential stream details
|
||||||
c_db.execute(
|
c_db.execute(
|
||||||
'CREATE TABLE IF NOT EXISTS session_history (id INTEGER PRIMARY KEY AUTOINCREMENT, '
|
'CREATE TABLE IF NOT EXISTS session_history (id INTEGER PRIMARY KEY AUTOINCREMENT, reference_id INTEGER, '
|
||||||
'started INTEGER, stopped INTEGER, rating_key INTEGER, user_id INTEGER, user TEXT, '
|
'started INTEGER, stopped INTEGER, rating_key INTEGER, user_id INTEGER, user TEXT, '
|
||||||
'ip_address TEXT, paused_counter INTEGER DEFAULT 0, player TEXT, platform TEXT, machine_id TEXT, '
|
'ip_address TEXT, paused_counter INTEGER DEFAULT 0, player TEXT, platform TEXT, machine_id TEXT, '
|
||||||
'parent_rating_key INTEGER, grandparent_rating_key INTEGER, media_type TEXT, view_offset INTEGER DEFAULT 0)'
|
'parent_rating_key INTEGER, grandparent_rating_key INTEGER, media_type TEXT, view_offset INTEGER DEFAULT 0)'
|
||||||
|
@ -624,6 +624,29 @@ def dbcheck():
|
||||||
logger.debug(u'User "Local" does not exist. Adding user.')
|
logger.debug(u'User "Local" does not exist. Adding user.')
|
||||||
c_db.execute('INSERT INTO users (user_id, username) VALUES (0, "Local")')
|
c_db.execute('INSERT INTO users (user_id, username) VALUES (0, "Local")')
|
||||||
|
|
||||||
|
# Upgrade session_history table from earlier versions
|
||||||
|
try:
|
||||||
|
c_db.execute('SELECT reference_id from session_history')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
logger.debug(u"Altering database. Updating database table session_history.")
|
||||||
|
c_db.execute(
|
||||||
|
'ALTER TABLE session_history ADD COLUMN reference_id INTEGER DEFAULT 0'
|
||||||
|
)
|
||||||
|
# Set reference_id to the first row where (user_id = previous row, rating_key != previous row) and user_id = user_id
|
||||||
|
c_db.execute(
|
||||||
|
'UPDATE session_history ' \
|
||||||
|
'SET reference_id = (SELECT (CASE \
|
||||||
|
WHEN (SELECT MIN(id) FROM session_history WHERE id > ( \
|
||||||
|
SELECT MAX(id) FROM session_history \
|
||||||
|
WHERE (user_id = t1.user_id AND rating_key <> t1.rating_key AND id < t1.id)) AND user_id = t1.user_id) IS NULL \
|
||||||
|
THEN (SELECT MIN(id) FROM session_history WHERE (user_id = t1.user_id)) \
|
||||||
|
ELSE (SELECT MIN(id) FROM session_history WHERE id > ( \
|
||||||
|
SELECT MAX(id) FROM session_history \
|
||||||
|
WHERE (user_id = t1.user_id AND rating_key <> t1.rating_key AND id < t1.id)) AND user_id = t1.user_id) END) ' \
|
||||||
|
'FROM session_history AS t1 ' \
|
||||||
|
'WHERE t1.id = session_history.id) '
|
||||||
|
)
|
||||||
|
|
||||||
conn_db.commit()
|
conn_db.commit()
|
||||||
c_db.close()
|
c_db.close()
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,36 @@ class ActivityProcessor(object):
|
||||||
# logger.debug(u"PlexPy ActivityProcessor :: Writing session_history transaction...")
|
# logger.debug(u"PlexPy ActivityProcessor :: Writing session_history transaction...")
|
||||||
self.db.action(query=query, args=args)
|
self.db.action(query=query, args=args)
|
||||||
|
|
||||||
|
# Check if we should group the session, select the last two rows from the user
|
||||||
|
query = 'SELECT id, rating_key, user_id, reference_id FROM session_history \
|
||||||
|
WHERE user_id = ? ORDER BY id DESC LIMIT 2 '
|
||||||
|
|
||||||
|
args = [session['user_id']]
|
||||||
|
|
||||||
|
result = self.db.select(query=query, args=args)
|
||||||
|
|
||||||
|
new_session = {'id': result[0][0],
|
||||||
|
'rating_key': result[0][1],
|
||||||
|
'user_id': result[0][2],
|
||||||
|
'reference_id': result[0][3]}
|
||||||
|
|
||||||
|
if len(result) == 1:
|
||||||
|
prev_session = None
|
||||||
|
else:
|
||||||
|
prev_session = {'id': result[1][0],
|
||||||
|
'rating_key': result[1][1],
|
||||||
|
'user_id': result[1][2],
|
||||||
|
'reference_id': result[1][3]}
|
||||||
|
|
||||||
|
query = 'UPDATE session_history SET reference_id = ? WHERE id = ? '
|
||||||
|
# If rating_key is the same in the previous session, then set the reference_id to the previous row, else set the reference_id to the new id
|
||||||
|
if (prev_session is not None) and (prev_session['rating_key'] == new_session['rating_key']):
|
||||||
|
args = [prev_session['reference_id'], new_session['id']]
|
||||||
|
else:
|
||||||
|
args = [new_session['id'], new_session['id']]
|
||||||
|
|
||||||
|
self.db.action(query=query, args=args)
|
||||||
|
|
||||||
# logger.debug(u"PlexPy ActivityProcessor :: Successfully written history item, last id for session_history is %s"
|
# logger.debug(u"PlexPy ActivityProcessor :: Successfully written history item, last id for session_history is %s"
|
||||||
# % last_id)
|
# % last_id)
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ _CONFIG_DEFINITIONS = {
|
||||||
'GIT_BRANCH': (str, 'General', 'master'),
|
'GIT_BRANCH': (str, 'General', 'master'),
|
||||||
'GIT_PATH': (str, 'General', ''),
|
'GIT_PATH': (str, 'General', ''),
|
||||||
'GIT_USER': (str, 'General', 'drzoidberg33'),
|
'GIT_USER': (str, 'General', 'drzoidberg33'),
|
||||||
|
'GROUP_HISTORY_TABLES': (int, 'General', 0),
|
||||||
'GROWL_ENABLED': (int, 'Growl', 0),
|
'GROWL_ENABLED': (int, 'Growl', 0),
|
||||||
'GROWL_HOST': (str, 'Growl', ''),
|
'GROWL_HOST': (str, 'Growl', ''),
|
||||||
'GROWL_PASSWORD': (str, 'Growl', ''),
|
'GROWL_PASSWORD': (str, 'Growl', ''),
|
||||||
|
|
|
@ -26,48 +26,48 @@ class DataFactory(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_history(self, kwargs=None, custom_where=None):
|
def get_history(self, kwargs=None, custom_where=None, grouping=0, watched_percent=85):
|
||||||
data_tables = datatables.DataTables()
|
data_tables = datatables.DataTables()
|
||||||
|
|
||||||
columns = ['session_history.id',
|
group_by = ['session_history.reference_id'] if grouping else ['session_history.id']
|
||||||
'session_history.started as date',
|
|
||||||
'(CASE WHEN users.friendly_name IS NULL THEN session_history'
|
columns = ['session_history.reference_id',
|
||||||
'.user ELSE users.friendly_name END) as friendly_name',
|
'session_history.id',
|
||||||
'session_history.player',
|
'started AS date',
|
||||||
'session_history.ip_address',
|
'MIN(started) AS started',
|
||||||
'session_history_metadata.full_title as full_title',
|
'MAX(stopped) AS stopped',
|
||||||
|
'SUM(CASE WHEN stopped > 0 THEN (stopped - started) ELSE 0 END) - \
|
||||||
|
SUM(CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) AS duration',
|
||||||
|
'SUM(CASE WHEN paused_counter IS NULL THEN 0 ELSE paused_counter END) AS paused_counter',
|
||||||
|
'session_history.user_id',
|
||||||
|
'session_history.user',
|
||||||
|
'(CASE WHEN users.friendly_name IS NULL THEN user ELSE users.friendly_name END) as friendly_name',
|
||||||
|
'player',
|
||||||
|
'ip_address',
|
||||||
|
'session_history_metadata.media_type',
|
||||||
|
'session_history_metadata.rating_key',
|
||||||
|
'session_history_metadata.parent_rating_key',
|
||||||
|
'session_history_metadata.grandparent_rating_key',
|
||||||
|
'session_history_metadata.full_title',
|
||||||
|
'session_history_metadata.parent_title',
|
||||||
|
'session_history_metadata.year',
|
||||||
|
'session_history_metadata.media_index',
|
||||||
|
'session_history_metadata.parent_media_index',
|
||||||
'session_history_metadata.thumb',
|
'session_history_metadata.thumb',
|
||||||
'session_history_metadata.parent_thumb',
|
'session_history_metadata.parent_thumb',
|
||||||
'session_history_metadata.grandparent_thumb',
|
'session_history_metadata.grandparent_thumb',
|
||||||
'session_history_metadata.media_index',
|
'((CASE WHEN view_offset IS NULL THEN 0.1 ELSE view_offset * 1.0 END) / \
|
||||||
'session_history_metadata.parent_media_index',
|
(CASE WHEN session_history_metadata.duration IS NULL THEN 1.0 ELSE session_history_metadata.duration * 1.0 END) * 100) AS percent_complete',
|
||||||
'session_history_metadata.parent_title',
|
|
||||||
'session_history_metadata.year',
|
|
||||||
'session_history.started',
|
|
||||||
'session_history.paused_counter',
|
|
||||||
'session_history.stopped',
|
|
||||||
'round((julianday(datetime(session_history.stopped, "unixepoch", "localtime")) - \
|
|
||||||
julianday(datetime(session_history.started, "unixepoch", "localtime"))) * 86400) - \
|
|
||||||
(CASE WHEN session_history.paused_counter IS NULL THEN 0 \
|
|
||||||
ELSE session_history.paused_counter END) as duration',
|
|
||||||
'((CASE WHEN session_history.view_offset IS NULL THEN 0.1 ELSE \
|
|
||||||
session_history.view_offset * 1.0 END) / \
|
|
||||||
(CASE WHEN session_history_metadata.duration IS NULL THEN 1.0 ELSE \
|
|
||||||
session_history_metadata.duration * 1.0 END) * 100) as percent_complete',
|
|
||||||
'session_history.grandparent_rating_key as grandparent_rating_key',
|
|
||||||
'session_history.parent_rating_key as parent_rating_key',
|
|
||||||
'session_history.rating_key as rating_key',
|
|
||||||
'session_history.user',
|
|
||||||
'session_history_metadata.media_type',
|
|
||||||
'session_history_media_info.video_decision',
|
'session_history_media_info.video_decision',
|
||||||
'session_history_media_info.audio_decision',
|
'session_history_media_info.audio_decision',
|
||||||
'session_history.user_id as user_id'
|
'COUNT(*) AS group_count',
|
||||||
|
'GROUP_CONCAT(session_history.id) AS group_ids'
|
||||||
]
|
]
|
||||||
try:
|
try:
|
||||||
query = data_tables.ssp_query(table_name='session_history',
|
query = data_tables.ssp_query(table_name='session_history',
|
||||||
columns=columns,
|
columns=columns,
|
||||||
custom_where=custom_where,
|
custom_where=custom_where,
|
||||||
group_by=[],
|
group_by=group_by,
|
||||||
join_types=['LEFT OUTER JOIN',
|
join_types=['LEFT OUTER JOIN',
|
||||||
'JOIN',
|
'JOIN',
|
||||||
'JOIN'],
|
'JOIN'],
|
||||||
|
@ -97,30 +97,40 @@ class DataFactory(object):
|
||||||
else:
|
else:
|
||||||
thumb = item["thumb"]
|
thumb = item["thumb"]
|
||||||
|
|
||||||
row = {"id": item['id'],
|
if item['percent_complete'] >= watched_percent:
|
||||||
"date": item['date'],
|
watched_status = 1
|
||||||
"friendly_name": item['friendly_name'],
|
elif item['percent_complete'] >= watched_percent/2:
|
||||||
"player": item["player"],
|
watched_status = 0.5
|
||||||
"ip_address": item["ip_address"],
|
else:
|
||||||
"full_title": item["full_title"],
|
watched_status = 0
|
||||||
"thumb": thumb,
|
|
||||||
"media_index": item["media_index"],
|
row = {"reference_id": item["reference_id"],
|
||||||
"parent_media_index": item["parent_media_index"],
|
"id": item["id"],
|
||||||
"parent_title": item["parent_title"],
|
"date": item["date"],
|
||||||
"year": item["year"],
|
|
||||||
"started": item["started"],
|
"started": item["started"],
|
||||||
"paused_counter": item["paused_counter"],
|
|
||||||
"stopped": item["stopped"],
|
"stopped": item["stopped"],
|
||||||
"duration": item["duration"],
|
"duration": item["duration"],
|
||||||
"percent_complete": item["percent_complete"],
|
"paused_counter": item["paused_counter"],
|
||||||
"grandparent_rating_key": item["grandparent_rating_key"],
|
"user_id": item["user_id"],
|
||||||
"parent_rating_key": item["parent_rating_key"],
|
|
||||||
"rating_key": item["rating_key"],
|
|
||||||
"user": item["user"],
|
"user": item["user"],
|
||||||
|
"friendly_name": item["friendly_name"],
|
||||||
|
"player": item["player"],
|
||||||
|
"ip_address": item["ip_address"],
|
||||||
"media_type": item["media_type"],
|
"media_type": item["media_type"],
|
||||||
|
"rating_key": item["rating_key"],
|
||||||
|
"parent_rating_key": item["parent_rating_key"],
|
||||||
|
"grandparent_rating_key": item["grandparent_rating_key"],
|
||||||
|
"full_title": item["full_title"],
|
||||||
|
"parent_title": item["parent_title"],
|
||||||
|
"year": item["year"],
|
||||||
|
"media_index": item["media_index"],
|
||||||
|
"parent_media_index": item["parent_media_index"],
|
||||||
|
"thumb": thumb,
|
||||||
"video_decision": item["video_decision"],
|
"video_decision": item["video_decision"],
|
||||||
"audio_decision": item["audio_decision"],
|
"audio_decision": item["audio_decision"],
|
||||||
"user_id": item["user_id"]
|
"watched_status": watched_status,
|
||||||
|
"group_count": item["group_count"],
|
||||||
|
"group_ids": item["group_ids"]
|
||||||
}
|
}
|
||||||
|
|
||||||
rows.append(row)
|
rows.append(row)
|
||||||
|
|
|
@ -458,7 +458,8 @@ class WebInterface(object):
|
||||||
"home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS,
|
"home_stats_cards": plexpy.CONFIG.HOME_STATS_CARDS,
|
||||||
"home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS,
|
"home_library_cards": plexpy.CONFIG.HOME_LIBRARY_CARDS,
|
||||||
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
"buffer_threshold": plexpy.CONFIG.BUFFER_THRESHOLD,
|
||||||
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT
|
"buffer_wait": plexpy.CONFIG.BUFFER_WAIT,
|
||||||
|
"group_history_tables": checked(plexpy.CONFIG.GROUP_HISTORY_TABLES)
|
||||||
}
|
}
|
||||||
|
|
||||||
return serve_template(templatename="settings.html", title="Settings", config=config)
|
return serve_template(templatename="settings.html", title="Settings", config=config)
|
||||||
|
@ -474,7 +475,8 @@ class WebInterface(object):
|
||||||
"tv_notify_on_start", "movie_notify_on_start", "music_notify_on_start",
|
"tv_notify_on_start", "movie_notify_on_start", "music_notify_on_start",
|
||||||
"tv_notify_on_stop", "movie_notify_on_stop", "music_notify_on_stop",
|
"tv_notify_on_stop", "movie_notify_on_stop", "music_notify_on_stop",
|
||||||
"tv_notify_on_pause", "movie_notify_on_pause", "music_notify_on_pause", "refresh_users_on_startup",
|
"tv_notify_on_pause", "movie_notify_on_pause", "music_notify_on_pause", "refresh_users_on_startup",
|
||||||
"ip_logging_enable", "video_logging_enable", "music_logging_enable", "pms_is_remote", "home_stats_type"
|
"ip_logging_enable", "video_logging_enable", "music_logging_enable", "pms_is_remote", "home_stats_type",
|
||||||
|
"group_history_tables"
|
||||||
]
|
]
|
||||||
for checked_config in checked_configs:
|
for checked_config in checked_configs:
|
||||||
if checked_config not in kwargs:
|
if checked_config not in kwargs:
|
||||||
|
@ -555,28 +557,38 @@ class WebInterface(object):
|
||||||
message=message, timer=timer, quote=quote)
|
message=message, timer=timer, quote=quote)
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def get_history(self, user=None, user_id=None, **kwargs):
|
def get_history(self, user=None, user_id=None, grouping=0, **kwargs):
|
||||||
|
|
||||||
|
if grouping == 'false':
|
||||||
|
grouping = 0
|
||||||
|
else:
|
||||||
|
grouping = plexpy.CONFIG.GROUP_HISTORY_TABLES
|
||||||
|
|
||||||
|
watched_percent = plexpy.CONFIG.NOTIFY_WATCHED_PERCENT
|
||||||
|
|
||||||
custom_where=[]
|
custom_where=[]
|
||||||
if user_id:
|
if user_id:
|
||||||
custom_where = [['user_id', user_id]]
|
custom_where = [['session_history.user_id', user_id]]
|
||||||
elif user:
|
elif user:
|
||||||
custom_where = [['user', user]]
|
custom_where = [['session_history.user', user]]
|
||||||
if 'rating_key' in kwargs:
|
if 'rating_key' in kwargs:
|
||||||
rating_key = kwargs.get('rating_key', "")
|
rating_key = kwargs.get('rating_key', "")
|
||||||
custom_where = [['rating_key', rating_key]]
|
custom_where = [['session_history.rating_key', rating_key]]
|
||||||
if 'parent_rating_key' in kwargs:
|
if 'parent_rating_key' in kwargs:
|
||||||
rating_key = kwargs.get('parent_rating_key', "")
|
rating_key = kwargs.get('parent_rating_key', "")
|
||||||
custom_where = [['parent_rating_key', rating_key]]
|
custom_where = [['session_history.parent_rating_key', rating_key]]
|
||||||
if 'grandparent_rating_key' in kwargs:
|
if 'grandparent_rating_key' in kwargs:
|
||||||
rating_key = kwargs.get('grandparent_rating_key', "")
|
rating_key = kwargs.get('grandparent_rating_key', "")
|
||||||
custom_where = [['grandparent_rating_key', rating_key]]
|
custom_where = [['session_history.grandparent_rating_key', rating_key]]
|
||||||
if 'start_date' in kwargs:
|
if 'start_date' in kwargs:
|
||||||
start_date = kwargs.get('start_date', "")
|
start_date = kwargs.get('start_date', "")
|
||||||
custom_where = [['strftime("%Y-%m-%d", datetime(date, "unixepoch", "localtime"))', start_date]]
|
custom_where = [['strftime("%Y-%m-%d", datetime(date, "unixepoch", "localtime"))', start_date]]
|
||||||
|
if 'reference_id' in kwargs:
|
||||||
|
reference_id = kwargs.get('reference_id', "")
|
||||||
|
custom_where = [['session_history.reference_id', reference_id]]
|
||||||
|
|
||||||
data_factory = datafactory.DataFactory()
|
data_factory = datafactory.DataFactory()
|
||||||
history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where)
|
history = data_factory.get_history(kwargs=kwargs, custom_where=custom_where, grouping=grouping, watched_percent=watched_percent)
|
||||||
|
|
||||||
cherrypy.response.headers['Content-type'] = 'application/json'
|
cherrypy.response.headers['Content-type'] = 'application/json'
|
||||||
return json.dumps(history)
|
return json.dumps(history)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue