Don't refresh users on every config save.

Don't reschedule all tasks on every config save.
Send pre-formatted month+year string for monthly total plays graph.
This commit is contained in:
Tim 2015-08-26 00:11:20 +02:00
parent 0a850fc3af
commit f56ba300ac
3 changed files with 22 additions and 10 deletions

View file

@ -25,11 +25,7 @@ var hc_plays_by_month_options = {
}, },
colors: ['#F9AA03', '#FFFFFF'], colors: ['#F9AA03', '#FFFFFF'],
xAxis: { xAxis: {
type: 'datetime',
labels: { labels: {
formatter: function() {
return moment(this.value).format("MMM YYYY");
},
style: { style: {
color: '#aaa' color: '#aaa'
} }

View file

@ -259,7 +259,7 @@ class Graphs(object):
dt = datetime.datetime(*month_item[:6]) dt = datetime.datetime(*month_item[:6])
date_string = dt.strftime('%Y-%m') date_string = dt.strftime('%Y-%m')
categories.append(date_string) categories.append(dt.strftime('%b %Y'))
series_1_value = 0 series_1_value = 0
series_2_value = 0 series_2_value = 0
for item in result: for item in result:

View file

@ -492,18 +492,34 @@ class WebInterface(object):
kwargs[plain_config] = kwargs[use_config] kwargs[plain_config] = kwargs[use_config]
del kwargs[use_config] del kwargs[use_config]
# Check if we should refresh our data
refresh_users = False
reschedule = False
if 'monitoring_interval' in kwargs and 'refresh_users_interval' in kwargs:
if (kwargs['monitoring_interval'] != str(plexpy.CONFIG.MONITORING_INTERVAL)) or \
(kwargs['refresh_users_interval'] != str(plexpy.CONFIG.REFRESH_USERS_INTERVAL)):
reschedule = True
if 'pms_ip' in kwargs:
if kwargs['pms_ip'] != plexpy.CONFIG.PMS_IP:
refresh_users = True
plexpy.CONFIG.process_kwargs(kwargs) plexpy.CONFIG.process_kwargs(kwargs)
# Write the config # Write the config
plexpy.CONFIG.write() plexpy.CONFIG.write()
# Reconfigure scheduler # Get new server URLs for SSL communications.
plexpy.initialize_scheduler()
plextv.get_real_pms_url() plextv.get_real_pms_url()
# Refresh users table. Probably shouldn't do this on every config save, will improve this later. # Reconfigure scheduler if intervals changed
threading.Thread(target=plextv.refresh_users).start() if reschedule:
plexpy.initialize_scheduler()
# Refresh users table if our server IP changes.
if refresh_users:
threading.Thread(target=plextv.refresh_users).start()
raise cherrypy.HTTPRedirect("settings") raise cherrypy.HTTPRedirect("settings")