Cleanup graphs PRs

This commit is contained in:
JonnyWong16 2017-03-04 15:33:45 -08:00
parent a3014638c8
commit c6ad09fe8f
5 changed files with 31 additions and 33 deletions

View file

@ -566,7 +566,7 @@ _CONFIG_DEFINITIONS = {
'UPDATE_LABELS': (int, 'General', 1),
'VERIFY_SSL_CERT': (bool_int, 'Advanced', 1),
'VIDEO_LOGGING_ENABLE': (int, 'Monitoring', 1),
'WEEK_START': (int, 'General', 0),
'WEEK_START_MONDAY': (int, 'General', 0),
'XBMC_ENABLED': (int, 'XBMC', 0),
'XBMC_HOST': (str, 'XBMC', ''),
'XBMC_PASSWORD': (str, 'XBMC', ''),

View file

@ -169,13 +169,12 @@ class Graphs(object):
logger.warn(u"PlexPy Graphs :: Unable to execute database query for get_total_plays_per_dayofweek: %s." % e)
return None
week_start = plexpy.CONFIG.WEEK_START
if (week_start == 1):
if plexpy.CONFIG.WEEK_START_MONDAY:
days_list = ['Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday', 'Sunday']
'Thursday', 'Friday', 'Saturday', 'Sunday']
else:
days_list = ['Sunday', 'Monday', 'Tuesday', 'Wednesday',
'Thursday', 'Friday', 'Saturday']
'Thursday', 'Friday', 'Saturday']
categories = []
series_1 = []
@ -335,19 +334,16 @@ class Graphs(object):
'GROUP BY strftime("%%Y-%%m", datetime(started, "unixepoch", "localtime")) ' \
'ORDER BY datestring DESC LIMIT %s' % (time_range, user_cond, time_range)
result = monitor_db.select(query)
result = monitor_db.select(query)
except Exception as e:
logger.warn(u"PlexPy Graphs :: Unable to execute database query for get_total_plays_per_month: %s." % e)
return None
# create our date range as some months may not have any data
# but we still want to display them
time_range = int(time_range)
x = time_range
base = time.localtime()
month_range = [time.localtime(
time.mktime((base.tm_year, base.tm_mon - n, 1, 0, 0, 0, 0, 0, 0))) for n in range(x)]
time.mktime((base.tm_year, base.tm_mon - n, 1, 0, 0, 0, 0, 0, 0))) for n in range(int(time_range))]
categories = []
series_1 = []

View file

@ -2623,7 +2623,7 @@ class WebInterface(object):
"imgur_client_id": plexpy.CONFIG.IMGUR_CLIENT_ID,
"cache_images": checked(plexpy.CONFIG.CACHE_IMAGES),
"pms_version": plexpy.CONFIG.PMS_VERSION,
"week_start": checked(plexpy.CONFIG.WEEK_START)
"week_start_monday": checked(plexpy.CONFIG.WEEK_START_MONDAY)
}
return serve_template(templatename="settings.html", title="Settings", config=config, kwargs=kwargs)
@ -2637,7 +2637,7 @@ class WebInterface(object):
checked_configs = [
"launch_browser", "enable_https", "https_create_cert", "api_enabled", "freeze_db", "check_github",
"grouping_global_history", "grouping_user_history", "grouping_charts", "group_history_tables",
"pms_use_bif", "pms_ssl", "pms_is_remote", "home_stats_type", "week_start",
"pms_use_bif", "pms_ssl", "pms_is_remote", "home_stats_type", "week_start_monday",
"movie_notify_enable", "tv_notify_enable", "music_notify_enable", "monitoring_use_websocket",
"refresh_libraries_on_startup", "refresh_users_on_startup",
"ip_logging_enable", "movie_logging_enable", "tv_logging_enable", "music_logging_enable",