diff --git a/data/interfaces/default/css/plexwatch.css b/data/interfaces/default/css/plexwatch.css index 23a4502b..c1e151f1 100644 --- a/data/interfaces/default/css/plexwatch.css +++ b/data/interfaces/default/css/plexwatch.css @@ -8101,4 +8101,52 @@ ol.test >li { } .charts-slider-title-views { float: right; +} + + +.home-platforms-instance-poster { + float: left; + height: 120px; + padding: 5px 10px 5px 10px; +} + +.home-platforms-instance-box { + float: left; + height: 80px; + width: 80px; + padding: 25px 10px 25px 10px; +} + +.home-platforms-instance-oval { + float: left; + height: 80px; + width: 80px; + padding: 25px 10px 25px 10px; + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + border-radius: 50%; +} + +.home-platforms-instance-name { + float: left; + color: #fff; + text-overflow: ellipsis; + overflow: hidden; + position: relative; + font-size: 13px; + line-height: 15px; + font-weight: bold; + width: 180px; + margin-left: 10px; + margin-top: 20px; +} + +.home-platforms-instance { + float: left; + width: 300px; + height: 130px; + padding: 5px; + background-color: #282828; + margin-right: 20px; + margin-bottom: 20px; } \ No newline at end of file diff --git a/data/interfaces/default/home_stats.html b/data/interfaces/default/home_stats.html index fc625316..8f548605 100644 --- a/data/interfaces/default/home_stats.html +++ b/data/interfaces/default/home_stats.html @@ -1,67 +1,79 @@ -% if stats[0]['rows']: -
- -
+ % endfor + + + % else: +
No stats for selected period.

+ % endif % else: -
No stats for selected period.

-% endif +
There was an error loading your PlexWatch data. Please check your settings.

+% endif \ No newline at end of file diff --git a/data/interfaces/default/index.html b/data/interfaces/default/index.html index f9300864..6fc066f3 100644 --- a/data/interfaces/default/index.html +++ b/data/interfaces/default/index.html @@ -31,14 +31,10 @@
-

Statistics - | 7 days - | 30 days - | 90 days -

+

Statistics (Past 30 days)

-
+
Loading stats...

@@ -129,22 +125,7 @@ }); }); - getHomeStats(7); - - $('#stats-7').click(function() { - $('#home-stats').html('
Loading stats...

'); - getHomeStats(7); - }); - - $('#stats-30').click(function() { - $('#home-stats').html('
Loading stats...

'); - getHomeStats(30); - }); - - $('#stats-90').click(function() { - $('#home-stats').html('
Loading stats...

'); - getHomeStats(90); - }); + getHomeStats(30); diff --git a/plexpy/plexwatch.py b/plexpy/plexwatch.py index b8e08359..625a67f7 100644 --- a/plexpy/plexwatch.py +++ b/plexpy/plexwatch.py @@ -581,13 +581,17 @@ class PlexWatch(object): for stat in stats_queries: if 'top_tv' in stat: top_tv = [] - query = 'SELECT orig_title, COUNT(orig_title) as total_plays, grandparentRatingKey, MAX(time) as last_watch, xml ' \ - 'FROM %s ' \ - 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ - 'AND episode != "" ' \ - 'GROUP BY orig_title ' \ - 'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range) - result = myDB.select(query) + try: + query = 'SELECT orig_title, COUNT(orig_title) as total_plays, grandparentRatingKey, MAX(time) as last_watch, xml ' \ + 'FROM %s ' \ + 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ + 'AND episode != "" ' \ + 'GROUP BY orig_title ' \ + 'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range) + result = myDB.select(query) + except: + logger.warn("Unable to open PlexWatch database.") + return None for item in result: xml_data = helpers.latinToAscii(item[4]) @@ -619,12 +623,16 @@ class PlexWatch(object): elif 'top_users' in stat: top_users = [] - query = 'SELECT user, COUNT(id) as total_plays, MAX(time) as last_watch ' \ - 'FROM %s ' \ - 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ - 'GROUP BY user ' \ - 'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range) - result = myDB.select(query) + try: + query = 'SELECT user, COUNT(id) as total_plays, MAX(time) as last_watch ' \ + 'FROM %s ' \ + 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ + 'GROUP BY user ' \ + 'ORDER BY total_plays DESC LIMIT 10' % (self.get_user_table_name(), time_range) + result = myDB.select(query) + except: + logger.warn("Unable to open PlexWatch database.") + return None for item in result: thumb = self.get_user_gravatar_image(item[0]) @@ -640,12 +648,17 @@ class PlexWatch(object): elif 'top_platforms' in stat: top_platform = [] - query = 'SELECT platform, COUNT(id) as total_plays, MAX(time) as last_watch, xml ' \ - 'FROM %s ' \ - 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ - 'GROUP BY platform ' \ - 'ORDER BY total_plays DESC' % (self.get_user_table_name(), time_range) - result = myDB.select(query) + + try: + query = 'SELECT platform, COUNT(id) as total_plays, MAX(time) as last_watch, xml ' \ + 'FROM %s ' \ + 'WHERE datetime(stopped, "unixepoch", "localtime") >= datetime("now", "-%s days", "localtime") ' \ + 'GROUP BY platform ' \ + 'ORDER BY total_plays DESC' % (self.get_user_table_name(), time_range) + result = myDB.select(query) + except: + logger.warn("Unable to open PlexWatch database.") + return None for item in result: xml_data = helpers.latinToAscii(item[3])