Commit b9989e83 authored by Vincent Pelletier's avatar Vincent Pelletier

Add forgotten support for loading multiple states.

parent 1deaa1a0
......@@ -407,6 +407,19 @@ class GenericSiteStats(object):
'apdex': _APDEXDateDictAsJSONState(self.apdex),
}
def accumulateFrom(self, other):
# XXX: ignoring: threshold, getDuration, suffix, error_detail.
# Assuming they are consistently set.
if self.error_detail:
for status, other_url_dict in other.error_url_count.iteritems():
url_dict = self.error_url_count[status]
for url, referer_list in other_url_dict.iteritems():
url_dict[url].extend(referer_list)
for attribute_id in ('url_apdex', 'apdex'):
self_attribute = getattr(self, attribute_id)
for key, apdex_data in getattr(other, attribute_id).iteritems():
self_attribute[key].accumulateFrom(apdex_data)
class ERP5SiteStats(GenericSiteStats):
"""
Heuristic used:
......@@ -558,6 +571,19 @@ class ERP5SiteStats(GenericSiteStats):
result['no_module'] = _APDEXDateDictAsJSONState(self.no_module)
return result
def accumulateFrom(self, other):
super(ERP5SiteStats, self).accumulateFrom(other)
module = self.module
for module_id, other_module_dict in other.module.iteritems():
module_dict = module[module_id]
for is_document, other_date_dict in other_module_dict.iteritems():
date_dict = module_dict[is_document]
for date, apdex in other_date_dict.iteritems():
date_dict[date].accumulateFrom(apdex)
no_module = self.no_module
for date, apdex in other.no_module.iteritems():
no_module[date].accumulateFrom(apdex)
DURATION_US_FORMAT = '%D'
DURATION_S_FORMAT = '%T'
......@@ -966,8 +992,12 @@ def main():
if action is None:
print >> sys.stderr, 'Info: no prefix match %r, stats skipped' % url
continue
per_site[site] = action.func.fromJSONState(site_state,
site_stats = action.func.fromJSONState(site_state,
getDuration, action.keywords['suffix'])
if site in per_site:
per_site[site].accumulateFrom(site_stats)
else:
per_site[site] = site_stats
print >> sys.stderr, 'done (%s)' % timedelta(seconds=time.time()
- load_start)
skip_user_agent = list(itertools.chain(*args.skip_user_agent))
......
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