Merge pull request #189 from JonnyWong16/miscellaneous-fixes

Fix for music on graphs, and fixes on homepage
This commit is contained in:
drzoidberg33 2015-09-17 20:26:48 +02:00
commit d23aaf91f7
5 changed files with 44 additions and 10 deletions

View file

@ -119,6 +119,8 @@ DOCUMENTATION :: END
% if a['type'] == 'track': % if a['type'] == 'track':
% if a['audio_decision'] == 'direct play': % if a['audio_decision'] == 'direct play':
Stream &nbsp;<strong>Direct Play</strong> Stream &nbsp;<strong>Direct Play</strong>
% elif a['audio_decision'] == 'copy':
Stream &nbsp;<strong>Direct Stream</strong>
% else: % else:
Stream &nbsp;<strong>Transcoding Stream &nbsp;<strong>Transcoding
(Speed: ${a['transcode_speed']}) (Speed: ${a['transcode_speed']})
@ -136,8 +138,10 @@ DOCUMENTATION :: END
Audio &nbsp;<strong>Transcode (${a['transcode_audio_codec']}) (${a['transcode_audio_channels']}ch)</strong> Audio &nbsp;<strong>Transcode (${a['transcode_audio_codec']}) (${a['transcode_audio_channels']}ch)</strong>
% endif % endif
% elif a['type'] == 'episode' or a['type'] == 'movie' or a['type'] == 'clip': % elif a['type'] == 'episode' or a['type'] == 'movie' or a['type'] == 'clip':
% if a['video_decision'] == 'direct play': % if a['video_decision'] == 'direct play' and a['audio_decision'] == 'direct play':
Stream &nbsp;<strong>Direct Play</strong> Stream &nbsp;<strong>Direct Play</strong>
% elif a['video_decision'] == 'copy' and a['audio_decision'] == 'copy':
Stream &nbsp;<strong>Direct Stream</strong>
% else: % else:
Stream &nbsp;<strong>Transcoding Stream &nbsp;<strong>Transcoding
(Speed: ${a['transcode_speed']}) (Speed: ${a['transcode_speed']})
@ -165,6 +169,8 @@ DOCUMENTATION :: END
% elif a['type'] == 'photo': % elif a['type'] == 'photo':
% if a['video_decision'] == 'direct play': % if a['video_decision'] == 'direct play':
Stream &nbsp;<strong>Direct Play</strong> Stream &nbsp;<strong>Direct Play</strong>
% elif a['video_decision'] == 'copy':
Stream &nbsp;<strong>Direct Stream</strong>
% else: % else:
Stream &nbsp;<strong> Stream &nbsp;<strong>
Transcoding Transcoding

View file

@ -294,6 +294,8 @@
$('a[data-toggle=tab][href=' + current_tab + ']').trigger('click'); $('a[data-toggle=tab][href=' + current_tab + ']').trigger('click');
} }
var music_visible = (${config['music_logging_enable']} == 1 ? true : false);
function loadGraphsTab1(time_range, yaxis) { function loadGraphsTab1(time_range, yaxis) {
setGraphFormat(yaxis); setGraphFormat(yaxis);
@ -319,6 +321,7 @@
hc_plays_by_day_options.yAxis.min = 0; hc_plays_by_day_options.yAxis.min = 0;
hc_plays_by_day_options.xAxis.categories = dateArray; hc_plays_by_day_options.xAxis.categories = dateArray;
hc_plays_by_day_options.series = data.series; hc_plays_by_day_options.series = data.series;
hc_plays_by_day_options.series[2].visible = music_visible;
var hc_plays_by_day = new Highcharts.Chart(hc_plays_by_day_options); var hc_plays_by_day = new Highcharts.Chart(hc_plays_by_day_options);
} }
}); });
@ -331,6 +334,7 @@
success: function(data) { success: function(data) {
hc_plays_by_dayofweek_options.xAxis.categories = data.categories; hc_plays_by_dayofweek_options.xAxis.categories = data.categories;
hc_plays_by_dayofweek_options.series = data.series; hc_plays_by_dayofweek_options.series = data.series;
hc_plays_by_dayofweek_options.series[2].visible = music_visible;
var hc_plays_by_dayofweek = new Highcharts.Chart(hc_plays_by_dayofweek_options); var hc_plays_by_dayofweek = new Highcharts.Chart(hc_plays_by_dayofweek_options);
} }
}); });
@ -343,6 +347,7 @@
success: function(data) { success: function(data) {
hc_plays_by_hourofday_options.xAxis.categories = data.categories; hc_plays_by_hourofday_options.xAxis.categories = data.categories;
hc_plays_by_hourofday_options.series = data.series; hc_plays_by_hourofday_options.series = data.series;
hc_plays_by_hourofday_options.series[2].visible = music_visible;
var hc_plays_by_hourofday = new Highcharts.Chart(hc_plays_by_hourofday_options); var hc_plays_by_hourofday = new Highcharts.Chart(hc_plays_by_hourofday_options);
} }
}); });
@ -355,6 +360,7 @@
success: function(data) { success: function(data) {
hc_plays_by_platform_options.xAxis.categories = data.categories; hc_plays_by_platform_options.xAxis.categories = data.categories;
hc_plays_by_platform_options.series = data.series; hc_plays_by_platform_options.series = data.series;
hc_plays_by_platform_options.series[2].visible = music_visible;
var hc_plays_by_platform = new Highcharts.Chart(hc_plays_by_platform_options); var hc_plays_by_platform = new Highcharts.Chart(hc_plays_by_platform_options);
} }
}); });
@ -367,6 +373,7 @@
success: function(data) { success: function(data) {
hc_plays_by_user_options.xAxis.categories = data.categories; hc_plays_by_user_options.xAxis.categories = data.categories;
hc_plays_by_user_options.series = data.series; hc_plays_by_user_options.series = data.series;
hc_plays_by_user_options.series[2].visible = music_visible;
var hc_plays_by_user = new Highcharts.Chart(hc_plays_by_user_options); var hc_plays_by_user = new Highcharts.Chart(hc_plays_by_user_options);
} }
}); });
@ -462,6 +469,7 @@
hc_plays_by_month_options.yAxis.min = 0; hc_plays_by_month_options.yAxis.min = 0;
hc_plays_by_month_options.xAxis.categories = data.categories; hc_plays_by_month_options.xAxis.categories = data.categories;
hc_plays_by_month_options.series = data.series; hc_plays_by_month_options.series = data.series;
hc_plays_by_month_options.series[2].visible = music_visible;
var hc_plays_by_month = new Highcharts.Chart(hc_plays_by_month_options); var hc_plays_by_month = new Highcharts.Chart(hc_plays_by_month_options);
} }
}); });

View file

@ -82,12 +82,15 @@
currentActivity(); currentActivity();
setInterval(currentActivity, 15000); setInterval(currentActivity, 15000);
function getHomeStats(days, stat_type, stat_count) { function getHomeStats(days, stat_type, stat_count, notify_watched_percent) {
$.ajax({ $.ajax({
url: 'home_stats', url: 'home_stats',
cache: false, cache: false,
async: true, async: true,
data: {time_range: days, stat_type: stat_type, stat_count: stat_count}, data: {time_range: days,
stat_type: stat_type,
stat_count: stat_count,
notify_watched_percent: notify_watched_percent},
complete: function(xhr, status) { complete: function(xhr, status) {
$("#home-stats").html(xhr.responseText); $("#home-stats").html(xhr.responseText);
} }
@ -165,7 +168,10 @@
} }
}); });
getHomeStats(${config['home_stats_length']}, ${config['home_stats_type']}, ${config['home_stats_count']}); getHomeStats(${config['home_stats_length']},
${config['home_stats_type']},
${config['home_stats_count']},
${config['notify_watched_percent']});
getLibraryStatsHeader(); getLibraryStatsHeader();
getLibraryStats(); getLibraryStats();

View file

@ -131,7 +131,7 @@ class DataFactory(object):
return dict return dict
def get_home_stats(self, time_range='30', stat_type='0', stat_count='5'): def get_home_stats(self, time_range='30', stat_type='0', stat_count='5', notify_watched_percent='85'):
monitor_db = database.MonitorDatabase() monitor_db = database.MonitorDatabase()
if not time_range.isdigit(): if not time_range.isdigit():
@ -432,7 +432,11 @@ class DataFactory(object):
'session_history_metadata.thumb, ' \ 'session_history_metadata.thumb, ' \
'session_history_metadata.grandparent_thumb, ' \ 'session_history_metadata.grandparent_thumb, ' \
'MAX(session_history.started) as last_watch, ' \ 'MAX(session_history.started) as last_watch, ' \
'session_history.player as platform ' \ 'session_history.player as platform, ' \
'((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 ' \
'FROM session_history_metadata ' \ 'FROM session_history_metadata ' \
'JOIN session_history ON session_history_metadata.id = session_history.id ' \ 'JOIN session_history ON session_history_metadata.id = session_history.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 ' \
@ -440,9 +444,10 @@ class DataFactory(object):
'>= datetime("now", "-%s days", "localtime") ' \ '>= datetime("now", "-%s days", "localtime") ' \
'AND (session_history_metadata.media_type = "movie" ' \ 'AND (session_history_metadata.media_type = "movie" ' \
'OR session_history_metadata.media_type = "episode") ' \ 'OR session_history_metadata.media_type = "episode") ' \
'AND percent_complete >= %s ' \
'GROUP BY session_history_metadata.full_title ' \ 'GROUP BY session_history_metadata.full_title ' \
'ORDER BY last_watch DESC ' \ 'ORDER BY last_watch DESC ' \
'LIMIT %s' % (time_range, stat_count) 'LIMIT %s' % (time_range, notify_watched_percent, stat_count)
result = monitor_db.select(query) result = monitor_db.select(query)
except: except:
logger.warn("Unable to execute database query.") logger.warn("Unable to execute database query.")

View file

@ -69,6 +69,7 @@ class WebInterface(object):
"home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE, "home_stats_type": plexpy.CONFIG.HOME_STATS_TYPE,
"home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT, "home_stats_count": plexpy.CONFIG.HOME_STATS_COUNT,
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER, "pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
"notify_watched_percent": plexpy.CONFIG.NOTIFY_WATCHED_PERCENT
} }
return serve_template(templatename="index.html", title="Home", config=config) return serve_template(templatename="index.html", title="Home", config=config)
@ -121,9 +122,12 @@ class WebInterface(object):
return json.dumps(formats) return json.dumps(formats)
@cherrypy.expose @cherrypy.expose
def home_stats(self, time_range='30', stat_type='0', stat_count='5', **kwargs): def home_stats(self, time_range='30', stat_type='0', stat_count='5', notify_watched_percent='85', **kwargs):
data_factory = datafactory.DataFactory() data_factory = datafactory.DataFactory()
stats_data = data_factory.get_home_stats(time_range=time_range, stat_type=stat_type, stat_count=stat_count) stats_data = data_factory.get_home_stats(time_range=time_range,
stat_type=stat_type,
stat_count=stat_count,
notify_watched_percent=notify_watched_percent)
return serve_template(templatename="home_stats.html", title="Stats", data=stats_data) return serve_template(templatename="home_stats.html", title="Stats", data=stats_data)
@ -144,7 +148,12 @@ class WebInterface(object):
@cherrypy.expose @cherrypy.expose
def graphs(self): def graphs(self):
return serve_template(templatename="graphs.html", title="Graphs")
config = {
"music_logging_enable": plexpy.CONFIG.MUSIC_LOGGING_ENABLE
}
return serve_template(templatename="graphs.html", title="Graphs", config=config)
@cherrypy.expose @cherrypy.expose
def sync(self): def sync(self):