mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Merge pull request #69 from jroyal/feature-show-most-watched-movie
Most watched movie is now on home page
This commit is contained in:
commit
65e42be278
2 changed files with 67 additions and 1 deletions
|
@ -93,6 +93,31 @@ DOCUMENTATION :: END
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
|
% elif a['stat_id'] == 'top_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 Watched 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]['total_plays']}</h3>
|
||||||
|
<p> plays</p>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
% elif a['stat_id'] == 'top_users' and a['rows']:
|
% elif a['stat_id'] == 'top_users' and a['rows']:
|
||||||
<div class="home-platforms-instance">
|
<div class="home-platforms-instance">
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -472,7 +472,8 @@ class DataFactory(object):
|
||||||
if not time_range.isdigit():
|
if not time_range.isdigit():
|
||||||
time_range = '30'
|
time_range = '30'
|
||||||
|
|
||||||
stats_queries = ["top_tv", "popular_tv", "top_users", "top_platforms"]
|
# This actually determines the output order in the home page
|
||||||
|
stats_queries = ["top_tv", "popular_tv", "top_movies", "top_users", "top_platforms"]
|
||||||
home_stats = []
|
home_stats = []
|
||||||
|
|
||||||
for stat in stats_queries:
|
for stat in stats_queries:
|
||||||
|
@ -516,6 +517,46 @@ class DataFactory(object):
|
||||||
home_stats.append({'stat_id': stat,
|
home_stats.append({'stat_id': stat,
|
||||||
'rows': top_tv})
|
'rows': top_tv})
|
||||||
|
|
||||||
|
elif 'top_movies' in stat:
|
||||||
|
top_movies = []
|
||||||
|
try:
|
||||||
|
query = 'SELECT session_history_metadata.id, ' \
|
||||||
|
'session_history_metadata.full_title, ' \
|
||||||
|
'COUNT(session_history_metadata.full_title) as total_plays, ' \
|
||||||
|
'session_history_metadata.rating_key, ' \
|
||||||
|
'MAX(session_history.started) as last_watch,' \
|
||||||
|
'session_history_metadata.thumb ' \
|
||||||
|
'FROM session_history_metadata ' \
|
||||||
|
'JOIN session_history on session_history_metadata.id = session_history.id ' \
|
||||||
|
'WHERE datetime(session_history.stopped, "unixepoch", "localtime") ' \
|
||||||
|
'>= datetime("now", "-%s days", "localtime") ' \
|
||||||
|
'AND session_history_metadata.media_type = "movie" ' \
|
||||||
|
'GROUP BY session_history_metadata.full_title ' \
|
||||||
|
'ORDER BY total_plays DESC LIMIT 10' % time_range
|
||||||
|
result = monitor_db.select(query)
|
||||||
|
except:
|
||||||
|
logger.warn("Unable to execute database query.")
|
||||||
|
return None
|
||||||
|
|
||||||
|
for item in result:
|
||||||
|
row = {'title': item[1],
|
||||||
|
'total_plays': item[2],
|
||||||
|
'users_watched': '',
|
||||||
|
'rating_key': item[3],
|
||||||
|
'last_play': item[4],
|
||||||
|
'grandparent_thumb': '',
|
||||||
|
'thumb': item[5],
|
||||||
|
'user': '',
|
||||||
|
'friendly_name': '',
|
||||||
|
'platform_type': '',
|
||||||
|
'platform': '',
|
||||||
|
'row_id': item[0]
|
||||||
|
}
|
||||||
|
top_movies.append(row)
|
||||||
|
|
||||||
|
home_stats.append({'stat_id': stat,
|
||||||
|
'rows': top_movies})
|
||||||
|
|
||||||
elif 'popular_tv' in stat:
|
elif 'popular_tv' in stat:
|
||||||
popular_tv = []
|
popular_tv = []
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue