forked from MechanisM/djangodash2011
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
ur001 edited this page Nov 18, 2014
·
14 revisions
Lets not create new axis for each dimension that is not "real true dimension". As is the case with DateAxis, you do not need to create a separate axis for year/month/day/hour/minute because you are not interested in the answer to "how many people visited my site every second day of the month", etc.
# Don't create axis "search_engine", "internal_page_name", "search_keyword",
# "link_url", etc. Instead create one hierarchical axis named "path"
metrica = Metrica(name='referer-stat', axes=[
('action', Axis()),
('path', HierarchicalAxis())
])
metrica.kick(action='pageview', path=('ext', 'SE', 'google', 'keyword1'))
metrica.kick(action='pageview', path=('ext', 'SE', 'yandex', 'keyword2'))
metrica.kick(action='pageview', path=('ext', 'link', 'sociation.org'))
metrica.kick(action='pageview', path=('int', 'main_page', 'top'))
# all views from external resources
>>> metrica.filter(path=('ext',)).total()
3
# all views from search engines
>>> metrica.filter(path=('ext', 'SE')).total()
2
# all search engines
>>> metrica.filter(path=('ext', 'SE')).iterate('path')
[(('ext', 'SE', 'google'), 1), (('ext', 'SE', 'yandex'), 1)]
- Added settings for key naming (allow to save memory with renaming
__all__
to-
, etc.) - Added unicode support
metrica.kick(action=u'привет')
- Added automatic type casting for simple Axis:
metrica = Metrica(name, axes=[('id', Axis(value_type=int))])
metrica.kick(id=1)
metrica.kick(id=2)
>>> metrica.iterate('id')
[(1, 1), (2, 1)]