diff --git a/data/interfaces/default/js/tables/history_table.js b/data/interfaces/default/js/tables/history_table.js index 530cdb89..ec086ba2 100644 --- a/data/interfaces/default/js/tables/history_table.js +++ b/data/interfaces/default/js/tables/history_table.js @@ -269,14 +269,13 @@ history_table_options = { // 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 - for (var i = rowData['reference_id']; i <= rowData['id']; i++) { - var index = $.inArray(i, 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) { - // if any child row is not selected, toggle parent button to warning - $(row).find('button[data-id="' + rowData['id'] + '"]').toggleClass('btn-warning').toggleClass('btn-danger'); - break; + $(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) { @@ -350,12 +349,13 @@ $('#history_table').on('click', '> tbody > tr > td.delete-control > button', fun // if grouped rows if ($(this).hasClass('btn-warning')) { // add all grouped rows to history_to_delete - for (var i = rowData['reference_id']; i <= rowData['id']; i++) { - var index = $.inArray(i, 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(i); + 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 @@ -363,12 +363,13 @@ $('#history_table').on('click', '> tbody > tr > td.delete-control > button', fun } } else { // remove all grouped rows to history_to_delete - for (var i = rowData['reference_id']; i <= rowData['id']; i++) { - var index = $.inArray(i, 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 @@ -553,14 +554,14 @@ function createChildTable(row, rowData) { 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 - for (var i = rowData['reference_id']; i <= rowData['id']; i++) { - var index = $.inArray(i, 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) { // if any child row is not selected, toggle parent button to warning - tr.parents('tr').prev().find('td.delete-control > button.btn-danger').toggleClass('btn-warning').toggleClass('btn-danger'); - break; + tr.parents('tr').prev().find('td.delete-control > button.btn-danger').addClass('btn-warning').removeClass('btn-danger'); } - } + }); }); } diff --git a/plexpy/datafactory.py b/plexpy/datafactory.py index dc53e9c8..421bc85e 100644 --- a/plexpy/datafactory.py +++ b/plexpy/datafactory.py @@ -59,9 +59,9 @@ class DataFactory(object): '((CASE WHEN view_offset IS NULL THEN 0.1 ELSE 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_media_info.video_decision', - 'COUNT(*) AS group_count', '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: query = data_tables.ssp_query(table_name='session_history', @@ -127,10 +127,10 @@ class DataFactory(object): "parent_media_index": item["parent_media_index"], "thumb": thumb, "video_decision": item["video_decision"], + "audio_decision": item["audio_decision"], "watched_status": watched_status, "group_count": item["group_count"], - "audio_decision": item["audio_decision"], - "user_id": item["user_id"] + "group_ids": item["group_ids"] } rows.append(row)