Commit 29f17be1 authored by Vincent Pelletier's avatar Vincent Pelletier

Add "--period year" support.

When analysing logs spanning over years, with monthly graph points.
parent fa53a437
......@@ -367,6 +367,11 @@ class AggregateSiteUrl(argparse.Action):
action = partial(action, prefix=value.count('/') + offset)
dest.append((value, action))
def _asMonthString(timestamp):
dt, tz = timestamp.split(' ')
_, month, year = dt.split(':', 1)[0].split('/')
return '%s/%02i' % (year, MONTH_VALUE_DICT[month])
def _asDayString(timestamp):
dt, tz = timestamp.split(' ')
day, month, year = dt.split(':', 1)[0].split('/')
......@@ -379,6 +384,7 @@ def _asHourString(timestamp):
return '%s/%02i/%s %s' % (year, MONTH_VALUE_DICT[month], day, hour)
period_parser = {
'year': (_asMonthString, lambda x: x.split('/', 1)[0], 'month'),
'month': (_asDayString, lambda x: '/'.join(x.split('/', 2)[:2]), 'day'),
'day': (_asHourString, lambda x: x.split(' ')[0], 'hour'),
}
......
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