Commit b4cd8161 authored by Vincent Pelletier's avatar Vincent Pelletier

Use consistent x range for all graphs on a page.

parent 5e2c3234
......@@ -85,6 +85,10 @@ ITEMGETTER1 = itemgetter(1)
APDEX_TOLERATING_COEF = 4
AUTO_PERIOD_COEF = 200
# Larger (x < LARGER_THAN_INTEGER_STR == True) than any string starting with
# a number
LARGER_THAN_INTEGER_STR = 'A'
def statusIsError(status):
return status[0] > '3'
......@@ -106,8 +110,8 @@ def getDataPoints(apdex_dict):
in sorted(apdex_dict.iteritems(), key=ITEMGETTER0)]
def prepareDataForGraph(daily_data, date_format, placeholder_delta,
coefficient_callback):
current_date = datetime.strptime(daily_data[0][0], date_format)
coefficient_callback, x_min=None, x_max=None):
current_date = datetime.strptime(x_min or daily_data[0][0], date_format)
new_daily_data = []
append = new_daily_data.append
for (measure_date_string, apdex, hit) in daily_data:
......@@ -120,6 +124,10 @@ def prepareDataForGraph(daily_data, date_format, placeholder_delta,
append((measure_date_string, apdex,
hit * coefficient_callback(measure_date)))
current_date = measure_date + placeholder_delta
if x_max is not None and current_date < datetime.strptime(x_max,
date_format):
append((current_date.strftime(date_format), 100, 0))
append((x_max, 100, 0))
return new_daily_data
def graphPair(daily_data, date_format, graph_period):
......@@ -320,7 +328,9 @@ class GenericSiteStats(object):
return getDataPoints(self.apdex)
def asHTML(self, date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, stat_filter=lambda x: x):
graph_coefficient, encoding, stat_filter=lambda x: x,
x_min=None, x_max=None,
):
result = []
append = result.append
apdex = APDEXStats(self.threshold, None)
......@@ -511,7 +521,8 @@ class ERP5SiteStats(GenericSiteStats):
self.no_module[value_date].accumulate(match)
def asHTML(self, date_format, placeholder_delta, graph_period, graph_coefficient,
encoding, stat_filter=lambda x: x):
encoding, stat_filter=lambda x: x, x_min=None, x_max=None,
):
result = []
append = result.append
append('<h2>Stats per module</h2><table class="stats stats_erp5"><tr>'
......@@ -570,6 +581,8 @@ class ERP5SiteStats(GenericSiteStats):
date_format,
placeholder_delta,
graph_coefficient,
x_min=x_min,
x_max=x_max,
),
date_format,
graph_period,
......@@ -607,7 +620,9 @@ class ERP5SiteStats(GenericSiteStats):
append('</tr></table>')
append(super(ERP5SiteStats, self).asHTML(date_format,
placeholder_delta, graph_period, graph_coefficient, encoding,
stat_filter=stat_filter))
stat_filter=stat_filter,
x_min=x_min, x_max=x_max,
))
return '\n'.join(result)
@classmethod
......@@ -918,9 +933,17 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
out.write('</table><h2>Hits per period</h2><table class="stats">'
'<tr><th>date</th><th>hits</th></tr>')
hit_per_day = defaultdict(int)
x_min = LARGER_THAN_INTEGER_STR
x_max = None
for site_data in per_site.itervalues():
for hit_date, _, hit in site_data.getApdexData():
hit_per_day[decimator(hit_date)] += hit
apdex_data_list = site_data.getApdexData()
if apdex_data_list:
x_min = min(x_min, apdex_data_list[0][0])
x_max = max(x_max, apdex_data_list[-1][0])
for hit_date, _, hit in apdex_data_list:
hit_per_day[decimator(hit_date)] += hit
if x_min == LARGER_THAN_INTEGER_STR:
x_min = None
for hit_date, hit in sorted(hit_per_day.iteritems(), key=ITEMGETTER0):
out.write('<tr><td>%s</td><td>%s</td></tr>' % (hit_date, hit))
out.write('</table>')
......@@ -936,13 +959,17 @@ def asHTML(out, encoding, per_site, args, default_site, period_parameter_dict,
date_format,
placeholder_delta,
graph_coefficient,
x_min=x_min,
x_max=x_max,
),
date_format,
graph_period,
)
)
out.write(data.asHTML(date_format, placeholder_delta, graph_period,
graph_coefficient, encoding, decimator))
graph_coefficient, encoding, decimator,
x_min=x_min, x_max=x_max,
))
end_stat_time = time.time()
if args.stats:
out.write('<h1>Parsing stats</h1><table class="stats">')
......
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