Commit 0b5086cf authored by Vincent Pelletier's avatar Vincent Pelletier

Add a parameter to fix y range on all graphs.

Default behaviour doesn't change.
If --fixed-yrange is provided with a negative value (default), ymax is
left floating.
If --fixed-yrange is provided with a value, ymax is fixed at that value.
parent b4cd8161
......@@ -130,7 +130,8 @@ def prepareDataForGraph(daily_data, date_format, placeholder_delta,
append((x_max, 100, 0))
return new_daily_data
def graphPair(daily_data, date_format, graph_period):
def graphPair(daily_data, date_format, graph_period, apdex_y_min=None,
hit_y_min=None, hit_y_max=None):
date_list = [int(calendar.timegm(time.strptime(x[0], date_format)) * 1000)
for x in daily_data]
timeformat = '%Y/<br/>%m/%d<br/> %H:%M'
......@@ -149,6 +150,7 @@ def graphPair(daily_data, date_format, graph_period):
'minTickSize': minTickSize,
},
'yaxis': {
'min': apdex_y_min,
'max': 100,
'axisLabel': 'apdex (%)',
'labelWidth': yLabelWidth,
......@@ -167,6 +169,8 @@ def graphPair(daily_data, date_format, graph_period):
'minTickSize': minTickSize,
},
'yaxis': {
'min': hit_y_min,
'max': hit_y_max,
'axisLabel': 'Hits',
'labelWidth': yLabelWidth,
'tickDecimals': 0,
......@@ -330,6 +334,7 @@ class GenericSiteStats(object):
def asHTML(self, date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, stat_filter=lambda x: x,
x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
):
result = []
append = result.append
......@@ -522,6 +527,7 @@ class ERP5SiteStats(GenericSiteStats):
def asHTML(self, date_format, placeholder_delta, graph_period, graph_coefficient,
encoding, stat_filter=lambda x: x, x_min=None, x_max=None,
apdex_y_min=None, hit_y_min=None, hit_y_max=None,
):
result = []
append = result.append
......@@ -586,6 +592,9 @@ class ERP5SiteStats(GenericSiteStats):
),
date_format,
graph_period,
apdex_y_min=apdex_y_min,
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
))
append('</div></div>')
append('</td>')
......@@ -622,6 +631,7 @@ class ERP5SiteStats(GenericSiteStats):
placeholder_delta, graph_period, graph_coefficient, encoding,
stat_filter=stat_filter,
x_min=x_min, x_max=x_max,
apdex_y_min=apdex_y_min, hit_y_min=hit_y_min, hit_y_max=hit_y_max,
))
return '\n'.join(result)
......@@ -882,6 +892,11 @@ period_parser = {
unquoteToHtml = lambda x, encoding: escape(unquote(x).decode(encoding,
'replace'))
apdex_y_scale_dict = {
'linear': None,
'log': 'log100To0',
}
def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
stats, site_caption_dict):
period = period_parameter_dict['period']
......@@ -890,6 +905,13 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
placeholder_delta = period_parameter_dict['placeholder_delta']
graph_period = period_parameter_dict['graph_period']
graph_coefficient = period_parameter_dict['graph_coefficient']
hit_y_max = args.fixed_yrange
if hit_y_max is not None:
apdex_y_min = hit_y_min = 0
if hit_y_max < 0:
hit_y_max = None
else:
apdex_y_min = hit_y_min = None
out.write('<!DOCTYPE html>\n<html><head><meta charset="%s">'
'<title>Stats</title>' % encoding)
js_path = getattr(args, 'js', None)
......@@ -964,11 +986,15 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
),
date_format,
graph_period,
apdex_y_min=apdex_y_min,
hit_y_min=hit_y_min,
hit_y_max=hit_y_max,
)
)
out.write(data.asHTML(date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, decimator,
x_min=x_min, x_max=x_max,
apdex_y_min=apdex_y_min, hit_y_min=hit_y_min, hit_y_max=hit_y_max,
))
end_stat_time = time.time()
if args.stats:
......@@ -1071,6 +1097,10 @@ def main():
help='Folder containing needed js files. Default: %(default)s')
group.add_argument('--js-embed', action='store_true',
help='Embed js files instead of linking to them.')
group.add_argument('--fixed-yrange', nargs='?', type=int, const=-1,
help='Fix graph vertical range: 0-100%% for apdex, 0-value for hits. '
'Negative value means hit max is adapted to data (used when this '
'argument is provided without value).')
group = parser.add_argument_group('site matching', 'Earlier arguments take '
'precedence. For example: --skip-base "/foo/bar(/|$|\\?)" '
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment