mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 05:31:15 -07:00
Reorganize home stats order
This commit is contained in:
parent
a5491eb58e
commit
d965d3c36e
3 changed files with 96 additions and 96 deletions
|
@ -74,10 +74,10 @@ DOCUMENTATION :: END
|
||||||
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
% if stat_id in ('top_movies', 'popular_movies', 'top_tv', 'popular_tv', 'top_music', 'popular_music', 'last_watched'):
|
||||||
<% fallback = 'art-live' if row0['live'] else 'art' %>
|
<% fallback = 'art-live' if row0['live'] else 'art' %>
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], row0['rating_key'], 500, 280, 40, '282828', 3, fallback=fallback)});">
|
||||||
% elif stat_id == 'top_platforms':
|
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background platform-${row0['platform_name']}-rgba no-image">
|
|
||||||
% elif stat_id == 'top_libraries':
|
% elif stat_id == 'top_libraries':
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], None, 500, 280, 40, '282828', 3, fallback='art')});">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background" style="background-image: url(${page('pms_image_proxy', row0['art'], None, 500, 280, 40, '282828', 3, fallback='art')});">
|
||||||
|
% elif stat_id == 'top_platforms':
|
||||||
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background platform-${row0['platform_name']}-rgba no-image">
|
||||||
% else:
|
% else:
|
||||||
<div id="stats-background-${stat_id}" class="dashboard-stats-background flat">
|
<div id="stats-background-${stat_id}" class="dashboard-stats-background flat">
|
||||||
% endif
|
% endif
|
||||||
|
@ -104,6 +104,12 @@ DOCUMENTATION :: END
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-${fallback.split('-')[0]}" style="background-image: url(${page('pms_image_proxy', row0['thumb'], row0['grandparent_rating_key'] or row0['rating_key'], 300, height, fallback=fallback)});"></div>
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-${fallback.split('-')[0]}" style="background-image: url(${page('pms_image_proxy', row0['thumb'], row0['grandparent_rating_key'] or row0['rating_key'], 300, height, fallback=fallback)});"></div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
% elif stat_id == 'top_libraries':
|
||||||
|
% if row0['thumb'].startswith('http'):
|
||||||
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat hidden-xs" style="background-image: url(${page('pms_image_proxy', row0['thumb'], None, 80, 80)});"></div>
|
||||||
|
% else:
|
||||||
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon library-${row0['section_type']} hidden-xs"></div>
|
||||||
|
% endif
|
||||||
% elif stat_id == 'top_users':
|
% elif stat_id == 'top_users':
|
||||||
<% user_href = page('user', row0['user_id']) if row0['user_id'] else '#' %>
|
<% user_href = page('user', row0['user_id']) if row0['user_id'] else '#' %>
|
||||||
<a id="stats-thumb-url-${stat_id}" href="${user_href}" title="${row0['user']}" class="hidden-xs">
|
<a id="stats-thumb-url-${stat_id}" href="${user_href}" title="${row0['user']}" class="hidden-xs">
|
||||||
|
@ -113,12 +119,6 @@ DOCUMENTATION :: END
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon platform-${row0['platform_name']} transparent hidden-xs"></div>
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon platform-${row0['platform_name']} transparent hidden-xs"></div>
|
||||||
% elif stat_id == 'most_concurrent':
|
% elif stat_id == 'most_concurrent':
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon stats-${stat_id} transparent hidden-xs"></div>
|
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon stats-${stat_id} transparent hidden-xs"></div>
|
||||||
% elif stat_id == 'top_libraries':
|
|
||||||
% if row0['thumb'].startswith('http'):
|
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat hidden-xs" style="background-image: url(${page('pms_image_proxy', row0['thumb'], None, 80, 80)});"></div>
|
|
||||||
% else:
|
|
||||||
<div id="stats-thumb-${stat_id}" class="dashboard-stats-flat svg-icon library-${row0['section_type']} hidden-xs"></div>
|
|
||||||
% endif
|
|
||||||
% endif
|
% endif
|
||||||
<div class="dashboard-stats-info-container">
|
<div class="dashboard-stats-info-container">
|
||||||
<div id="stats-title-${stat_id}" class="dashboard-stats-info-title">
|
<div id="stats-title-${stat_id}" class="dashboard-stats-info-title">
|
||||||
|
@ -158,6 +158,11 @@ DOCUMENTATION :: END
|
||||||
<a href="${href}" title="${row['title']}">
|
<a href="${href}" title="${row['title']}">
|
||||||
${row['title']}
|
${row['title']}
|
||||||
</a>
|
</a>
|
||||||
|
% elif stat_id == 'top_libraries':
|
||||||
|
<% library_href = page('library', row['section_id']) %>
|
||||||
|
<a href="${library_href}" title="${row['section_name']}">
|
||||||
|
${row['section_name']}
|
||||||
|
</a>
|
||||||
% elif stat_id == 'top_users':
|
% elif stat_id == 'top_users':
|
||||||
<% user_href = page('user', row['user_id']) if row['user_id'] else '#' %>
|
<% user_href = page('user', row['user_id']) if row['user_id'] else '#' %>
|
||||||
<a href="${user_href}" title="${row['user']}">
|
<a href="${user_href}" title="${row['user']}">
|
||||||
|
@ -167,11 +172,6 @@ DOCUMENTATION :: END
|
||||||
${row['platform']}
|
${row['platform']}
|
||||||
% elif stat_id == 'most_concurrent':
|
% elif stat_id == 'most_concurrent':
|
||||||
${row['title']}
|
${row['title']}
|
||||||
% elif stat_id == 'top_libraries':
|
|
||||||
<% library_href = page('library', row['section_id']) %>
|
|
||||||
<a href="${library_href}" title="${row['section_name']}">
|
|
||||||
${row['section_name']}
|
|
||||||
</a>
|
|
||||||
% endif
|
% endif
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-count">
|
<div class="sub-count">
|
||||||
|
|
|
@ -800,6 +800,16 @@
|
||||||
|
|
||||||
if (stat_id === 'most_concurrent') {
|
if (stat_id === 'most_concurrent') {
|
||||||
return
|
return
|
||||||
|
} else if (stat_id === 'top_libraries') {
|
||||||
|
$('#stats-background-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', art, null, 500, 280, 40, '282828', 3, fallback_art) + ')');
|
||||||
|
$('#stats-thumb-' + stat_id).removeClass(function (index, className) {
|
||||||
|
return (className.match (/(^|\s)svg-icon library-\S+/g) || []).join(' ')});
|
||||||
|
if (thumb.startsWith('http')) {
|
||||||
|
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', thumb, null, 300, 300, null, null, null, 'cover') + ')');
|
||||||
|
} else {
|
||||||
|
$('#stats-thumb-' + stat_id).css('background-image', '')
|
||||||
|
.addClass('svg-icon library-' + library_type);
|
||||||
|
}
|
||||||
} else if (stat_id === 'top_users') {
|
} else if (stat_id === 'top_users') {
|
||||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + (user_thumb || 'images/gravatar-default.png') + ')');
|
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + (user_thumb || 'images/gravatar-default.png') + ')');
|
||||||
if (user_id) {
|
if (user_id) {
|
||||||
|
@ -813,16 +823,6 @@
|
||||||
$('#stats-background-' + stat_id).removeClass(function (index, className) {
|
$('#stats-background-' + stat_id).removeClass(function (index, className) {
|
||||||
return (className.match (/(^|\s)platform-\S+/g) || []).join(' ');
|
return (className.match (/(^|\s)platform-\S+/g) || []).join(' ');
|
||||||
}).addClass('platform-' + $(elem).data('platform') + '-rgba');
|
}).addClass('platform-' + $(elem).data('platform') + '-rgba');
|
||||||
} else if (stat_id === 'top_libraries') {
|
|
||||||
$('#stats-background-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', art, null, 500, 280, 40, '282828', 3, fallback_art) + ')');
|
|
||||||
$('#stats-thumb-' + stat_id).removeClass(function (index, className) {
|
|
||||||
return (className.match (/(^|\s)svg-icon library-\S+/g) || []).join(' ')});
|
|
||||||
if (thumb.startsWith('http')) {
|
|
||||||
$('#stats-thumb-' + stat_id).css('background-image', 'url(' + page('pms_image_proxy', thumb, null, 300, 300, null, null, null, 'cover') + ')');
|
|
||||||
} else {
|
|
||||||
$('#stats-thumb-' + stat_id).css('background-image', '')
|
|
||||||
.addClass('svg-icon library-' + library_type);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (rating_key) {
|
if (rating_key) {
|
||||||
if (live) {
|
if (live) {
|
||||||
|
|
|
@ -645,6 +645,79 @@ class DataFactory(object):
|
||||||
'stat_title': 'Most Popular Artists',
|
'stat_title': 'Most Popular Artists',
|
||||||
'rows': session.mask_session_info(popular_music)})
|
'rows': session.mask_session_info(popular_music)})
|
||||||
|
|
||||||
|
elif stat == 'top_libraries':
|
||||||
|
top_libraries = []
|
||||||
|
|
||||||
|
try:
|
||||||
|
query = 'SELECT section_id, section_name, section_type, thumb AS library_thumb, ' \
|
||||||
|
'custom_thumb_url AS custom_thumb, art AS library_art, custom_art_url AS custom_art ' \
|
||||||
|
'FROM library_sections ' \
|
||||||
|
'WHERE deleted_section = 0'
|
||||||
|
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn("Tautulli DataFactory :: Unable to execute database query for get_home_stats: top_libraries: %s." % e)
|
||||||
|
return None
|
||||||
|
|
||||||
|
library_data = libraries.Libraries()
|
||||||
|
|
||||||
|
for item in result:
|
||||||
|
library_item = library_data.get_watch_time_stats(section_id=item['section_id'],
|
||||||
|
grouping=grouping,
|
||||||
|
query_days=time_range)
|
||||||
|
|
||||||
|
if not library_item or library_item[0]['total_plays'] == 0 and library_item[0]['total_time'] == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
library_watched = library_data.get_recently_watched(section_id=item['section_id'],
|
||||||
|
limit='1')
|
||||||
|
last_play = library_watched[0]['time'] if library_watched else 0
|
||||||
|
|
||||||
|
if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
|
||||||
|
library_thumb = item['custom_thumb']
|
||||||
|
elif item['library_thumb']:
|
||||||
|
library_thumb = item['library_thumb']
|
||||||
|
else:
|
||||||
|
library_thumb = common.DEFAULT_COVER_THUMB
|
||||||
|
|
||||||
|
if item['custom_art'] and item['custom_art'] != item['library_art']:
|
||||||
|
library_art = item['custom_art']
|
||||||
|
else:
|
||||||
|
library_art = item['library_art']
|
||||||
|
|
||||||
|
row = {
|
||||||
|
'total_plays': library_item[0]['total_plays'],
|
||||||
|
'total_duration': library_item[0]['total_time'],
|
||||||
|
'section_type': item['section_type'],
|
||||||
|
'section_name': item['section_name'],
|
||||||
|
'section_id': item['section_id'],
|
||||||
|
'last_play': last_play,
|
||||||
|
'thumb': library_thumb,
|
||||||
|
'grandparent_thumb': '',
|
||||||
|
'art': library_art,
|
||||||
|
'user': '',
|
||||||
|
'friendly_name': '',
|
||||||
|
'users_watched': '',
|
||||||
|
'rating_key': '',
|
||||||
|
'grandparent_rating_key': '',
|
||||||
|
'title': '',
|
||||||
|
'platform': '',
|
||||||
|
'row_id': ''
|
||||||
|
}
|
||||||
|
|
||||||
|
top_libraries.append(row)
|
||||||
|
|
||||||
|
home_stats.append({
|
||||||
|
'stat_id': stat,
|
||||||
|
'stat_type': sort_type,
|
||||||
|
'stat_title': 'Most Active Libraries',
|
||||||
|
'rows': session.mask_session_info(
|
||||||
|
sorted(top_libraries,
|
||||||
|
key=lambda k: k[sort_type],
|
||||||
|
reverse=True)[stats_start:stats_start + stats_count],
|
||||||
|
mask_metadata=False)
|
||||||
|
})
|
||||||
|
|
||||||
elif stat == 'top_users':
|
elif stat == 'top_users':
|
||||||
top_users = []
|
top_users = []
|
||||||
try:
|
try:
|
||||||
|
@ -901,79 +974,6 @@ class DataFactory(object):
|
||||||
'stat_title': 'Most Concurrent Streams',
|
'stat_title': 'Most Concurrent Streams',
|
||||||
'rows': most_concurrent})
|
'rows': most_concurrent})
|
||||||
|
|
||||||
elif stat == 'top_libraries':
|
|
||||||
top_libraries = []
|
|
||||||
|
|
||||||
try:
|
|
||||||
query = 'SELECT section_id, section_name, section_type, thumb AS library_thumb, ' \
|
|
||||||
'custom_thumb_url AS custom_thumb, art AS library_art, custom_art_url AS custom_art ' \
|
|
||||||
'FROM library_sections ' \
|
|
||||||
'WHERE deleted_section = 0'
|
|
||||||
|
|
||||||
result = monitor_db.select(query)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warn("Tautulli DataFactory :: Unable to execute database query for get_home_stats: top_libraries: %s." % e)
|
|
||||||
return None
|
|
||||||
|
|
||||||
library_data = libraries.Libraries()
|
|
||||||
|
|
||||||
for item in result:
|
|
||||||
library_item = library_data.get_watch_time_stats(section_id=item['section_id'],
|
|
||||||
grouping=grouping,
|
|
||||||
query_days=time_range)
|
|
||||||
|
|
||||||
if not library_item or library_item[0]['total_plays'] == 0 and library_item[0]['total_time'] == 0:
|
|
||||||
continue
|
|
||||||
|
|
||||||
library_watched = library_data.get_recently_watched(section_id=item['section_id'],
|
|
||||||
limit='1')
|
|
||||||
last_play = library_watched[0]['time'] if library_watched else 0
|
|
||||||
|
|
||||||
if item['custom_thumb'] and item['custom_thumb'] != item['library_thumb']:
|
|
||||||
library_thumb = item['custom_thumb']
|
|
||||||
elif item['library_thumb']:
|
|
||||||
library_thumb = item['library_thumb']
|
|
||||||
else:
|
|
||||||
library_thumb = common.DEFAULT_COVER_THUMB
|
|
||||||
|
|
||||||
if item['custom_art'] and item['custom_art'] != item['library_art']:
|
|
||||||
library_art = item['custom_art']
|
|
||||||
else:
|
|
||||||
library_art = item['library_art']
|
|
||||||
|
|
||||||
row = {
|
|
||||||
'total_plays': library_item[0]['total_plays'],
|
|
||||||
'total_duration': library_item[0]['total_time'],
|
|
||||||
'section_type': item['section_type'],
|
|
||||||
'section_name': item['section_name'],
|
|
||||||
'section_id': item['section_id'],
|
|
||||||
'last_play': last_play,
|
|
||||||
'thumb': library_thumb,
|
|
||||||
'grandparent_thumb': '',
|
|
||||||
'art': library_art,
|
|
||||||
'user': '',
|
|
||||||
'friendly_name': '',
|
|
||||||
'users_watched': '',
|
|
||||||
'rating_key': '',
|
|
||||||
'grandparent_rating_key': '',
|
|
||||||
'title': '',
|
|
||||||
'platform': '',
|
|
||||||
'row_id': ''
|
|
||||||
}
|
|
||||||
|
|
||||||
top_libraries.append(row)
|
|
||||||
|
|
||||||
home_stats.append({
|
|
||||||
'stat_id': stat,
|
|
||||||
'stat_type': sort_type,
|
|
||||||
'stat_title': 'Most Active Libraries',
|
|
||||||
'rows': session.mask_session_info(
|
|
||||||
sorted(top_libraries,
|
|
||||||
key=lambda k: k[sort_type],
|
|
||||||
reverse=True)[stats_start:stats_start + stats_count],
|
|
||||||
mask_metadata=False)
|
|
||||||
})
|
|
||||||
|
|
||||||
if stat_id and home_stats:
|
if stat_id and home_stats:
|
||||||
return home_stats[0]
|
return home_stats[0]
|
||||||
return home_stats
|
return home_stats
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue