Update to homepage statistics

* Added most popular movie to homepage
* New setting to toggle statistics based on play duration instead of
play count
This commit is contained in:
JonnyWong16 2015-08-18 12:32:41 -07:00
parent 58474d9565
commit 5c94b21bd1
6 changed files with 153 additions and 26 deletions

View file

@ -21,10 +21,11 @@ grandparent_thumb Returns location of the item's thumbnail. Use with pms_i
rating_key Returns the unique identifier for the media item.
title Returns the title for the associated stat.
== Only if 'stat_id' is 'top_tv' or 'top_user' or 'top_platform' ==
== Only if 'stat_id' is 'top_tv' or 'top_movies' or 'top_user' or 'top_platform' ==
total_plays Returns the count for the associated stat.
total_duration Returns the total duration for the associated stat.
== Only of 'stat_id' is 'popular_tv' ==
== Only of 'stat_id' is 'popular_tv' or 'popular_movies' ==
users_watched Returns the count for the associated stat.
== Only if 'stat_id' is 'top_user' ==
@ -63,8 +64,13 @@ DOCUMENTATION :: END
</a></h5>
</div>
<div class="user-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
</div>
</li>
</div>
@ -113,8 +119,38 @@ DOCUMENTATION :: END
</a></h5>
</div>
<div class="user-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
</div>
</li>
</div>
% elif a['stat_id'] == 'popular_movies' and a['rows']:
<div class="home-platforms-instance">
<li>
<span>
<a href="info?item_id=${a['rows'][0]['rating_key']}">
% if a['rows'][0]['thumb']:
<img class="home-platforms-instance-poster"
src="pms_image_proxy?img=${a['rows'][0]['thumb']}&width=162&height=240&fallback=poster">
% else:
<img class="home-platforms-instance-poster" src="interfaces/default/images/poster.png">
% endif
</a>
</span>
<div class="home-platforms-instance-name">
<h4>Most Popular Movie</h4>
<h5><a href="info?item_id=${a['rows'][0]['rating_key']}">
${a['rows'][0]['title']}
</a></h5>
</div>
<div class="user-platforms-instance-playcount">
<h3>${a['rows'][0]['users_watched']}</h3>
<p> users</p>
</div>
</li>
</div>
@ -149,8 +185,13 @@ DOCUMENTATION :: END
</h5>
</div>
<div class="user-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
</div>
</li>
</div>
@ -165,8 +206,13 @@ DOCUMENTATION :: END
<h5>${a['rows'][0]['platform_type']}</h5>
</div>
<div class="user-platforms-instance-playcount">
% if a['stat_type'] == 'total_plays':
<h3>${a['rows'][0]['total_plays']}</h3>
<p> plays</p>
% else:
<h3>${a['rows'][0]['total_duration']}</h3>
<p> mins</p>
% endif
</div>
</li>
</div>

View file

@ -45,12 +45,12 @@
<script src="interfaces/default/js/moment-with-locale.js"></script>
<script>
function getHomeStats(days) {
function getHomeStats(days, plays) {
$.ajax({
url: 'home_stats',
cache: false,
async: true,
data: {time_range: days},
data: {time_range: days, stat_type: plays},
complete: function(xhr, status) {
$("#home-stats").html(xhr.responseText);
}
@ -110,7 +110,7 @@
});
});
getHomeStats(${config['home_stats_length']});
getHomeStats(${config['home_stats_length']}, ${config['home_stats_type']});
</script>

View file

@ -280,8 +280,12 @@ available_notification_agents = notifiers.available_notification_agents()
<p class="help-block">If you have media indexing enabled on your server, use these on the activity pane.</p>
</div>
<div class="padded-header">
<h3>Homepage Statistics</h3>
</div>
<div class="form-group">
<label for="home_stats_length">Homepage Statistics Time Frame</label>
<label for="home_stats_length">Time Frame</label>
<div class="row">
<div class="col-md-2">
<input type="text" class="form-control" data-parsley-type="integer" id="home_stats_length" name="home_stats_length" value="${config['home_stats_length']}" size="3" data-parsley-min="0" data-parsley-trigger="change" required>
@ -289,6 +293,12 @@ available_notification_agents = notifiers.available_notification_agents()
</div>
<p class="help-block">Specify the number of days for the statistics on the home page. Default is 30 days.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox" id="home_stats_type" name="home_stats_type" value="1" ${config['home_stats_type']}> Use play duration
</label>
<p class="help-block">Use play duration instead of play count to generate statistics.</p>
</div>
<div class="padded-header">
<h3>Plex Logs</h3>