Commit cdd5d088 authored by Vincent Pelletier's avatar Vincent Pelletier

ERP5 stats: separate ERP5Site_viewSearchResult from "(other)".

parent a445c919
...@@ -448,6 +448,7 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -448,6 +448,7 @@ class ERP5SiteStats(GenericSiteStats):
self.module = defaultdict(partial(defaultdict, partial( self.module = defaultdict(partial(defaultdict, partial(
defaultdict, partial(APDEXStats, threshold, getDuration)))) defaultdict, partial(APDEXStats, threshold, getDuration))))
self.no_module = defaultdict(partial(APDEXStats, threshold, getDuration)) self.no_module = defaultdict(partial(APDEXStats, threshold, getDuration))
self.site_search = defaultdict(partial(APDEXStats, threshold, getDuration))
def rescale(self, convert, getDuration): def rescale(self, convert, getDuration):
super(ERP5SiteStats, self).rescale(convert, getDuration) super(ERP5SiteStats, self).rescale(convert, getDuration)
...@@ -458,10 +459,11 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -458,10 +459,11 @@ class ERP5SiteStats(GenericSiteStats):
for date, data in date_dict.iteritems(): for date, data in date_dict.iteritems():
new_date_dict[convert(date)].accumulateFrom(data) new_date_dict[convert(date)].accumulateFrom(data)
document_dict[is_document] = new_date_dict document_dict[is_document] = new_date_dict
new_no_module = defaultdict(partial(APDEXStats, threshold, getDuration)) for attribute_id in ('no_module', 'site_search'):
for date, data in self.no_module.iteritems(): attribute = defaultdict(partial(APDEXStats, threshold, getDuration))
new_no_module[convert(date)].accumulateFrom(data) for date, data in getattr(self, attribute_id).iteritems():
self.no_module = new_no_module attribute[convert(date)].accumulateFrom(data)
setattr(self, attribute_id, attribute)
def accumulate(self, match, url_match, date): def accumulate(self, match, url_match, date):
split = self.suffix(url_match.group('url')).split('?', 1)[0].split('/') split = self.suffix(url_match.group('url')).split('?', 1)[0].split('/')
...@@ -471,6 +473,8 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -471,6 +473,8 @@ class ERP5SiteStats(GenericSiteStats):
self.module[module][ self.module[module][
len(split) > 1 and (split[1] != 'view' and '_view' not in split[1]) len(split) > 1 and (split[1] != 'view' and '_view' not in split[1])
][date].accumulate(match) ][date].accumulate(match)
elif split and split[0] == 'ERP5Site_viewSearchResult':
self.site_search[date].accumulate(match)
else: else:
self.no_module[date].accumulate(match) self.no_module[date].accumulate(match)
...@@ -502,6 +506,11 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -502,6 +506,11 @@ class ERP5SiteStats(GenericSiteStats):
for date, value in self.no_module.iteritems(): for date, value in self.no_module.iteritems():
filtered_no_module[stat_filter(date)].accumulateFrom(value) filtered_no_module[stat_filter(date)].accumulateFrom(value)
column_set = set(filtered_no_module) column_set = set(filtered_no_module)
filtered_site_search = defaultdict(partial(APDEXStats, self.threshold,
None))
for date, value in self.site_search.iteritems():
filtered_site_search[stat_filter(date)].accumulateFrom(value)
column_set.update(filtered_site_search)
for key, is_document_dict in self.module.iteritems(): for key, is_document_dict in self.module.iteritems():
filtered_is_document_dict = filtered_module[key] filtered_is_document_dict = filtered_module[key]
for key, data_dict in is_document_dict.iteritems(): for key, data_dict in is_document_dict.iteritems():
...@@ -556,11 +565,17 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -556,11 +565,17 @@ class ERP5SiteStats(GenericSiteStats):
append('<tr class="group_top group_bottom"><th colspan="2">(none)</th>') append('<tr class="group_top group_bottom"><th colspan="2">(none)</th>')
hiddenGraph(self.no_module, '(none)') hiddenGraph(self.no_module, '(none)')
no_module_overall = apdexAsColumns(filtered_no_module) no_module_overall = apdexAsColumns(filtered_no_module)
append('<tr class="group_top group_bottom"><th colspan="2">site search'
'</th>')
hiddenGraph(self.site_search, 'site search')
site_search_overall = apdexAsColumns(filtered_site_search)
append('</tr></table><h2>Per-level overall</h2><table class="stats"><tr>' append('</tr></table><h2>Per-level overall</h2><table class="stats"><tr>'
'<th>level</th>') '<th>level</th>')
append(APDEXStats.asHTMLHeader()) append(APDEXStats.asHTMLHeader())
append('</tr><tr><th>top</th>') append('</tr><tr><th>top</th>')
append(no_module_overall.asHTML(self.threshold)) append(no_module_overall.asHTML(self.threshold))
append('</tr><tr><th>site search</th>')
append(site_search_overall.asHTML(self.threshold))
append('</tr><tr><th>module</th>') append('</tr><tr><th>module</th>')
append(module_document_overall[False].asHTML(self.threshold)) append(module_document_overall[False].asHTML(self.threshold))
append('</tr><tr><th>document</th>') append('</tr><tr><th>document</th>')
...@@ -579,9 +594,10 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -579,9 +594,10 @@ class ERP5SiteStats(GenericSiteStats):
date_dict = module_dict[is_document == 'true'] date_dict = module_dict[is_document == 'true']
for date, apdex_state in date_dict_state.iteritems(): for date, apdex_state in date_dict_state.iteritems():
date_dict[date] = APDEXStats.fromJSONState(apdex_state, getDuration) date_dict[date] = APDEXStats.fromJSONState(apdex_state, getDuration)
no_module = result.no_module for attribute_id in ('no_module', 'site_search'):
for date, apdex_state in state['no_module'].iteritems(): attribute = getattr(result, attribute_id)
no_module[date] = APDEXStats.fromJSONState(apdex_state, getDuration) for date, apdex_state in state[attribute_id].iteritems():
attribute[date] = APDEXStats.fromJSONState(apdex_state, getDuration)
return result return result
def asJSONState(self): def asJSONState(self):
...@@ -591,7 +607,9 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -591,7 +607,9 @@ class ERP5SiteStats(GenericSiteStats):
module_dict_state = module[module_id] = {} module_dict_state = module[module_id] = {}
for is_document, date_dict in module_dict.iteritems(): for is_document, date_dict in module_dict.iteritems():
module_dict_state[is_document] = _APDEXDateDictAsJSONState(date_dict) module_dict_state[is_document] = _APDEXDateDictAsJSONState(date_dict)
result['no_module'] = _APDEXDateDictAsJSONState(self.no_module) for attribute_id in ('no_module', 'site_search'):
result[attribute_id] = _APDEXDateDictAsJSONState(getattr(self,
attribute_id))
return result return result
def accumulateFrom(self, other): def accumulateFrom(self, other):
...@@ -603,9 +621,10 @@ class ERP5SiteStats(GenericSiteStats): ...@@ -603,9 +621,10 @@ class ERP5SiteStats(GenericSiteStats):
date_dict = module_dict[is_document] date_dict = module_dict[is_document]
for date, apdex in other_date_dict.iteritems(): for date, apdex in other_date_dict.iteritems():
date_dict[date].accumulateFrom(apdex) date_dict[date].accumulateFrom(apdex)
no_module = self.no_module for attribute_id in ('no_module', 'site_search'):
for date, apdex in other.no_module.iteritems(): attribute = getattr(self, attribute_id)
no_module[date].accumulateFrom(apdex) for date, apdex in getattr(other, attribute_id).iteritems():
attribute[date].accumulateFrom(apdex)
DURATION_US_FORMAT = '%D' DURATION_US_FORMAT = '%D'
DURATION_S_FORMAT = '%T' DURATION_S_FORMAT = '%T'
......
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