Fix broken search on history tables.

Fix bug in history search which wouldn't search for full title.
Fix bug where user info pages crashes if user no longer in friends list.
Fix bug with query structure, mainly affected incomplete user IP list.
User user id on Top user in home stats.
Add missing Xbox icon.
This commit is contained in:
Tim 2015-07-17 21:47:27 +02:00
parent 30c20b3061
commit dd90f2e375
7 changed files with 32 additions and 13 deletions

View file

@ -44,6 +44,7 @@ from plexpy import helpers
<th class="never" align='left' id="user"></th> <th class="never" align='left' id="user"></th>
<th class="never" align='left' id="media_type"></th> <th class="never" align='left' id="media_type"></th>
<th class="never" align='left' id="video_decision"></th> <th class="never" align='left' id="video_decision"></th>
<th class="never" align='left' id="user_id"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -28,6 +28,7 @@ users_watched Returns the count for the associated stat.
== Only if 'stat_id' is 'top_user' == == Only if 'stat_id' is 'top_user' ==
thumb Returns url of the user's gravatar. Returns '' if none exists. thumb Returns url of the user's gravatar. Returns '' if none exists.
user Returns the username for the associated stat. user Returns the username for the associated stat.
user_id Returns the user id for the associated stat.
friendly_name Returns the friendly name of the user for the associated stat. friendly_name Returns the friendly name of the user for the associated stat.
== Only if 'stat_id' is 'top_platform' == == Only if 'stat_id' is 'top_platform' ==
@ -112,7 +113,7 @@ DOCUMENTATION :: END
<div class="home-platforms-instance-name"> <div class="home-platforms-instance-name">
<h4>Most Active User</h4> <h4>Most Active User</h4>
<a href="user?user=${a['rows'][0]['user']}"> <a href="user?user_id=${a['rows'][0]['user_id']}">
<h5>${a['rows'][0]['friendly_name']}</h5> <h5>${a['rows'][0]['friendly_name']}</h5>
</a> </a>
</div> </div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -89,8 +89,8 @@ history_table_options = {
}, },
{ {
"targets": [5], "targets": [5],
"data":"title", "data":"full_title",
"name":"title", "name":"full_title",
"createdCell": function (td, cellData, rowData, row, col) { "createdCell": function (td, cellData, rowData, row, col) {
if (cellData !== '') { if (cellData !== '') {
if (rowData['media_type'] === 'movie' || rowData['media_type'] === 'episode') { if (rowData['media_type'] === 'movie' || rowData['media_type'] === 'episode') {
@ -198,6 +198,12 @@ history_table_options = {
"data":"video_decision", "data":"video_decision",
"searchable":false, "searchable":false,
"visible":false "visible":false
},
{
"targets": [16],
"data":"user_id",
"searchable":false,
"visible":false
} }

View file

@ -198,6 +198,7 @@ from plexpy import helpers
<th class="never" align='left' id="user"></th> <th class="never" align='left' id="user"></th>
<th class="never" align='left' id="media_type"></th> <th class="never" align='left' id="media_type"></th>
<th class="never" align='left' id="video_decision"></th> <th class="never" align='left' id="video_decision"></th>
<th class="never" align='left' id="user_id"></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -146,7 +146,7 @@ class DataFactory(object):
'.user ELSE users.friendly_name END) as friendly_name', '.user ELSE users.friendly_name END) as friendly_name',
t1 + '.player as platform', t1 + '.player as platform',
t1 + '.ip_address', t1 + '.ip_address',
t2 + '.full_title as title', t2 + '.full_title as full_title',
t1 + '.started', t1 + '.started',
t1 + '.paused_counter', t1 + '.paused_counter',
t1 + '.stopped', t1 + '.stopped',
@ -195,7 +195,7 @@ class DataFactory(object):
"friendly_name": item['friendly_name'], "friendly_name": item['friendly_name'],
"platform": item["platform"], "platform": item["platform"],
"ip_address": item["ip_address"], "ip_address": item["ip_address"],
"title": item["title"], "full_title": item["full_title"],
"started": item["started"], "started": item["started"],
"paused_counter": item["paused_counter"], "paused_counter": item["paused_counter"],
"stopped": item["stopped"], "stopped": item["stopped"],
@ -259,7 +259,7 @@ class DataFactory(object):
columns = ['session_history.started as last_seen', columns = ['session_history.started as last_seen',
'session_history.ip_address as ip_address', 'session_history.ip_address as ip_address',
'COUNT(session_history.ip_address) as play_count', 'COUNT(session_history.id) as play_count',
'session_history.player as platform', 'session_history.player as platform',
'session_history_metadata.full_title as last_watched', 'session_history_metadata.full_title as last_watched',
'session_history.user as user', 'session_history.user as user',
@ -413,9 +413,17 @@ class DataFactory(object):
'LIMIT 1' 'LIMIT 1'
result = monitor_db.select(query, args=[user, user]) result = monitor_db.select(query, args=[user, user])
elif user_id: elif user_id:
query = 'SELECT user_id, username, friendly_name, email, thumb, ' \ query = 'SELECT user_id, username, friendly_name, email, ' \
'is_home_user, is_allow_sync, is_restricted FROM users WHERE user_id = ? LIMIT 1' 'thumb, is_home_user, is_allow_sync, is_restricted ' \
result = monitor_db.select(query, args=[user_id]) 'FROM users ' \
'WHERE user_id = ? ' \
'UNION ALL ' \
'SELECT user_id, user, null, null, null, null, null, null ' \
'FROM session_history ' \
'WHERE user_id = ? ' \
'GROUP BY user ' \
'LIMIT 1'
result = monitor_db.select(query, args=[user_id, user_id])
if result: if result:
for item in result: for item in result:
if not item['friendly_name']: if not item['friendly_name']:
@ -540,7 +548,8 @@ class DataFactory(object):
'users.friendly_name end) as friendly_name,' \ 'users.friendly_name end) as friendly_name,' \
'COUNT(session_history.id) as total_plays, ' \ 'COUNT(session_history.id) as total_plays, ' \
'MAX(session_history.started) as last_watch, ' \ 'MAX(session_history.started) as last_watch, ' \
'users.thumb ' \ 'users.thumb, ' \
'users.user_id ' \
'FROM session_history ' \ 'FROM session_history ' \
'JOIN session_history_metadata ON session_history.id = session_history_metadata.id ' \ 'JOIN session_history_metadata ON session_history.id = session_history_metadata.id ' \
'LEFT OUTER JOIN users ON session_history.user_id = users.user_id ' \ 'LEFT OUTER JOIN users ON session_history.user_id = users.user_id ' \
@ -560,6 +569,7 @@ class DataFactory(object):
user_thumb = item[4] user_thumb = item[4]
row = {'user': item[0], row = {'user': item[0],
'user_id': item[5],
'friendly_name': item[1], 'friendly_name': item[1],
'total_plays': item[2], 'total_plays': item[2],
'last_play': item[3], 'last_play': item[3],

View file

@ -80,9 +80,9 @@ class DataTables(object):
% (column_data['column_string'], table_name, join, group_by, % (column_data['column_string'], table_name, join, group_by,
where, order) where, order)
else: else:
query = 'SELECT * FROM (SELECT * FROM (SELECT %s FROM %s %s GROUP BY %s) %s %s) %s' \ query = 'SELECT * FROM (SELECT %s FROM %s %s %s GROUP BY %s) %s %s' \
% (column_data['column_string'], table_name, join, group_by, % (column_data['column_string'], table_name, join, custom_where, group_by,
where, order, custom_where) where, order)
else: else:
if custom_where == '': if custom_where == '':
query = 'SELECT %s FROM %s %s %s %s' \ query = 'SELECT %s FROM %s %s %s %s' \