mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 16:22:57 -07:00
Add "player" to tables
* Also rename user platforms to user players * Fix other platform vs. player ambiguities
This commit is contained in:
parent
f1c4bf6249
commit
2616e14c83
15 changed files with 128 additions and 61 deletions
|
@ -42,6 +42,7 @@ class DataFactory(object):
|
|||
'session_history.user_id',
|
||||
'session_history.user',
|
||||
'(CASE WHEN users.friendly_name IS NULL THEN user ELSE users.friendly_name END) as friendly_name',
|
||||
'platform',
|
||||
'player',
|
||||
'ip_address',
|
||||
'session_history_metadata.media_type',
|
||||
|
@ -104,6 +105,12 @@ class DataFactory(object):
|
|||
else:
|
||||
watched_status = 0
|
||||
|
||||
# Rename Mystery platform names
|
||||
platform_names = {'Mystery 3': 'Playstation 3',
|
||||
'Mystery 4': 'Playstation 4',
|
||||
'Mystery 5': 'Xbox 360'}
|
||||
platform = platform_names.get(item["platform"], item["platform"])
|
||||
|
||||
row = {"reference_id": item["reference_id"],
|
||||
"id": item["id"],
|
||||
"date": item["date"],
|
||||
|
@ -114,6 +121,7 @@ class DataFactory(object):
|
|||
"user_id": item["user_id"],
|
||||
"user": item["user"],
|
||||
"friendly_name": item["friendly_name"],
|
||||
"platform": platform,
|
||||
"player": item["player"],
|
||||
"ip_address": item["ip_address"],
|
||||
"media_type": item["media_type"],
|
||||
|
|
|
@ -32,7 +32,8 @@ class Users(object):
|
|||
'MAX(session_history.started) as last_seen',
|
||||
'session_history.ip_address as ip_address',
|
||||
'COUNT(session_history.id) as plays',
|
||||
'session_history.player as platform',
|
||||
'session_history.platform as platform',
|
||||
'session_history.player as player',
|
||||
'session_history_metadata.full_title as last_watched',
|
||||
'session_history_metadata.thumb',
|
||||
'session_history_metadata.parent_thumb',
|
||||
|
@ -83,12 +84,19 @@ class Users(object):
|
|||
else:
|
||||
user_thumb = item['user_thumb']
|
||||
|
||||
# Rename Mystery platform names
|
||||
platform_names = {'Mystery 3': 'Playstation 3',
|
||||
'Mystery 4': 'Playstation 4',
|
||||
'Mystery 5': 'Xbox 360'}
|
||||
platform = platform_names.get(item["platform"], item["platform"])
|
||||
|
||||
row = {"id": item['id'],
|
||||
"plays": item['plays'],
|
||||
"last_seen": item['last_seen'],
|
||||
"friendly_name": item['friendly_name'],
|
||||
"ip_address": item['ip_address'],
|
||||
"platform": item['platform'],
|
||||
"platform": platform,
|
||||
"player": item['player'],
|
||||
"last_watched": item['last_watched'],
|
||||
"thumb": thumb,
|
||||
"media_type": item['media_type'],
|
||||
|
@ -121,7 +129,8 @@ class Users(object):
|
|||
'session_history.started as last_seen',
|
||||
'session_history.ip_address as ip_address',
|
||||
'COUNT(session_history.id) as play_count',
|
||||
'session_history.player as platform',
|
||||
'session_history.platform as platform',
|
||||
'session_history.player as player',
|
||||
'session_history_metadata.full_title as last_watched',
|
||||
'session_history_metadata.thumb',
|
||||
'session_history_metadata.parent_thumb',
|
||||
|
@ -169,11 +178,18 @@ class Users(object):
|
|||
else:
|
||||
thumb = item["thumb"]
|
||||
|
||||
# Rename Mystery platform names
|
||||
platform_names = {'Mystery 3': 'Playstation 3',
|
||||
'Mystery 4': 'Playstation 4',
|
||||
'Mystery 5': 'Xbox 360'}
|
||||
platform = platform_names.get(item["platform"], item["platform"])
|
||||
|
||||
row = {"id": item['id'],
|
||||
"last_seen": item['last_seen'],
|
||||
"ip_address": item['ip_address'],
|
||||
"play_count": item['play_count'],
|
||||
"platform": item['platform'],
|
||||
"platform": platform,
|
||||
"player": item['player'],
|
||||
"last_watched": item['last_watched'],
|
||||
"thumb": thumb,
|
||||
"media_type": item['media_type'],
|
||||
|
@ -490,10 +506,10 @@ class Users(object):
|
|||
|
||||
return user_watch_time_stats
|
||||
|
||||
def get_user_platform_stats(self, user=None, user_id=None):
|
||||
def get_user_player_stats(self, user=None, user_id=None):
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
||||
platform_stats = []
|
||||
player_stats = []
|
||||
result_id = 0
|
||||
|
||||
try:
|
||||
|
@ -522,12 +538,12 @@ class Users(object):
|
|||
'Mystery 5': 'Xbox 360'}
|
||||
platform_type = platform_names.get(item[2], item[2])
|
||||
|
||||
row = {'platform_name': item[0],
|
||||
row = {'player_name': item[0],
|
||||
'platform_type': platform_type,
|
||||
'total_plays': item[1],
|
||||
'result_id': result_id
|
||||
}
|
||||
platform_stats.append(row)
|
||||
player_stats.append(row)
|
||||
result_id += 1
|
||||
|
||||
return platform_stats
|
||||
return player_stats
|
|
@ -813,17 +813,17 @@ class WebInterface(object):
|
|||
return serve_template(templatename="user_watch_time_stats.html", data=None, title="Watch Stats")
|
||||
|
||||
@cherrypy.expose
|
||||
def get_user_platform_stats(self, user=None, user_id=None, **kwargs):
|
||||
def get_user_player_stats(self, user=None, user_id=None, **kwargs):
|
||||
|
||||
user_data = users.Users()
|
||||
result = user_data.get_user_platform_stats(user_id=user_id, user=user)
|
||||
result = user_data.get_user_player_stats(user_id=user_id, user=user)
|
||||
|
||||
if result:
|
||||
return serve_template(templatename="user_platform_stats.html", data=result,
|
||||
title="Platform Stats")
|
||||
return serve_template(templatename="user_player_stats.html", data=result,
|
||||
title="Player Stats")
|
||||
else:
|
||||
logger.warn('Unable to retrieve data.')
|
||||
return serve_template(templatename="user_platform_stats.html", data=None, title="Platform Stats")
|
||||
return serve_template(templatename="user_player_stats.html", data=None, title="Player Stats")
|
||||
|
||||
@cherrypy.expose
|
||||
def get_item_children(self, rating_key='', **kwargs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue