Implement new home page stats (still needs styling)

This commit is contained in:
Tim 2015-06-21 23:25:45 +02:00
parent 9364b06c99
commit 112d5f0efa
4 changed files with 267 additions and 1 deletions

View file

@ -83,6 +83,13 @@ class WebInterface(object):
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(formats)
@cherrypy.expose
def home_stats(self, time_range='30', **kwargs):
plex_watch = plexwatch.PlexWatch()
stats_data = plex_watch.get_home_stats(time_range)
return serve_template(templatename="home_stats.html", title="Stats", stats=stats_data)
@cherrypy.expose
def history(self):
return serve_template(templatename="history.html", title="History")
@ -671,6 +678,18 @@ class WebInterface(object):
plex_watch = plexwatch.PlexWatch()
result = plex_watch.get_user_gravatar_image(user)
if result:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(result)
else:
logger.warn('Unable to retrieve data.')
@cherrypy.expose
def get_home_stats(self, time_range='30', **kwargs):
plex_watch = plexwatch.PlexWatch()
result = plex_watch.get_home_stats(time_range)
if result:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps(result)