annotate MoinMoin/stats/hitcounts.py @ 3243:1ad6243cdf06

macros: refactor for new arg parser
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 12 Mar 2008 00:23:45 +0100
parents 2620aa4811a4
children 94a6f5fbf8b7
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Hitcount Statistics
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5 This macro creates a hitcount chart from the data in "event.log".
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6
1832
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
7 TODO: refactor to use a class, this code is ugly.
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
8 A lot of code here is duplicated in stats.useragents.
b180f047d918 comments only: cleaned up TODO, XXX, ...
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
9 Maybe both can use same base class, maybe some parts are useful to other code.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
10
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
11 @copyright: 2002-2004 Juergen Hermann <jh@web.de>,
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
12 2007 MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 _debug = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
18 import time
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
19
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
20 from MoinMoin import caching, wikiutil, logfile
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 from MoinMoin.Page import Page
749
3dba26fcfde0 moved logfile/logfile.py to logfile/__init__.py
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 682
diff changeset
22 from MoinMoin.logfile import eventlog
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
24 # this is a CONSTANT used for on-disk caching, it must NOT be configurable and
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
25 # not depend on request.user!
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
26 DATE_FMT = '%04d-%02d-%02d' # % (y, m, d)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 def linkto(pagename, request, params=''):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 _ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 if not request.cfg.chart_options:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 return text(pagename, request, params)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 if _debug:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 return draw(pagename, request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 page = Page(request, pagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39 # Create escaped query string from dict and params
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40 querystr = {'action': 'chart', 'type': 'hitcounts'}
102
a54cebaab73e move make / parse query string functions to wikiutil, make unicode-safe
Thomas Waldmann <tw@waldmann-edv.de>
parents: 68
diff changeset
41 querystr = wikiutil.makeQueryString(querystr)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 querystr = wikiutil.escape(querystr)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 if params:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 querystr += '&amp;' + params
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
45
1816
4a31739bc6e1 Page.url(): removed escaping support
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
46 data = {'url': page.url(request, querystr)}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 data.update(request.cfg.chart_options)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 result = ('<img src="%(url)s" width="%(width)d" height="%(height)d"'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 ' alt="hitcounts chart">') % data
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 def get_data(pagename, request, filterpage=None):
1017
2408963718c8 fix scope for single-page hitcounts
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 995
diff changeset
55 cache_days, cache_views, cache_edits = [], [], []
2408963718c8 fix scope for single-page hitcounts
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 995
diff changeset
56 cache_date = 0
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
57
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 # Get results from cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 if filterpage:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 arena = Page(request, pagename)
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
61 cache = caching.CacheEntry(request, arena, 'hitcounts', scope='item', use_pickle=True)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 arena = 'charts'
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
64 cache = caching.CacheEntry(request, arena, 'hitcounts', scope='wiki', use_pickle=True)
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
65
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 if cache.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67 try:
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
68 cache_date, cache_days, cache_views, cache_edits = cache.content()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69 except:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 cache.remove() # cache gone bad
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72 # Get new results from the log
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73 log = eventlog.EventLog(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75 new_date = log.date()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 except logfile.LogMissing:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 new_date = None
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
78
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 # prepare data
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 days = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 views = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82 edits = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 ratchet_day = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
84 ratchet_time = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85 if new_date is not None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 log.set_filter(['VIEWPAGE', 'SAVEPAGE'])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 for event in log.reverse():
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
88 event_usecs = event[0]
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
89 if event_usecs <= cache_date:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
90 break
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
91 eventpage = event[2].get('pagename', '')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92 if filterpage and eventpage != filterpage:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
93 continue
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
94 event_secs = wikiutil.version2timestamp(event_usecs)
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
95 time_tuple = time.gmtime(event_secs) # must be UTC
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
96 day = tuple(time_tuple[0:3])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97 if day != ratchet_day:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98 # new day
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
99 while ratchet_time:
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
100 ratchet_time -= 86400 # seconds per day
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
101 rday = tuple(time.gmtime(ratchet_time)[0:3]) # must be UTC
1988
dbf2b7426385 fixed some pylint warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
102 if rday <= day:
dbf2b7426385 fixed some pylint warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
103 break
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
104 days.append(DATE_FMT % rday)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105 views.append(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106 edits.append(0)
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
107 days.append(DATE_FMT % day)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 views.append(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
109 edits.append(0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
110 ratchet_day = day
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
111 ratchet_time = event_secs
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 if event[1] == 'VIEWPAGE':
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
113 views[-1] += 1
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114 elif event[1] == 'SAVEPAGE':
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
115 edits[-1] += 1
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
116
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 days.reverse()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118 views.reverse()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 edits.reverse()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
120
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121 # merge the day on the end of the cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 if cache_days and days and days[0] == cache_days[-1]:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
123 cache_edits[-1] += edits[0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124 cache_views[-1] += views[0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
125 days, views, edits = days[1:], views[1:], edits[1:]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
126
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
127 # Update and save the cache
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
128 cache_days.extend(days)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
129 cache_views.extend(views)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
130 cache_edits.extend(edits)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
131 if new_date is not None:
2970
2620aa4811a4 stats: hitcounts: use fixed date format for cache, use utc in any case, use pickle, useragents: use pickle (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2802
diff changeset
132 cache.update((new_date, cache_days, cache_views, cache_edits))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
133
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134 return cache_days, cache_views, cache_edits
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
135
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
136
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
137 def text(pagename, request, params=''):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 from MoinMoin.util.dataset import TupleDataset, Column
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139 from MoinMoin.widget.browser import DataBrowserWidget
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140 _ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
141
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
142 # check params
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
143 filterpage = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
144 if params.startswith('page='):
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
145 params = params[len('page='):]
2802
6309a258f094 fix hitcounts
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
146 params = wikiutil.url_unquote(params, want_unicode=False)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147 filterpage = wikiutil.decodeUserInput(params)
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
148
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1866
diff changeset
149 if request and request.form and 'page' in request.form:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
150 filterpage = request.form['page'][0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
151
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
152 days, views, edits = get_data(pagename, request, filterpage)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
153
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
154 hits = TupleDataset()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
155 hits.columns = [Column('day', label=_("Date"), align='left'),
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
156 Column('views', label=_("Views/day"), align='right'),
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
157 Column('edits', label=_("Edits/day"), align='right'),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
158 ]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
159
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
160 maxentries = 30
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
161
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
162 if maxentries < len(days):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
163 step = float(len(days))/ maxentries
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
164 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
165 step = 1
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
166
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
167 sv = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
168 se = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
169 sd = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
170 cnt = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
171
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
172 for i in xrange(len(days)-1, -1, -1):
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
173 d, v, e = days[i], views[i], edits[i]
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1988
diff changeset
174 # sum up views and edits to step days
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
175 sd += 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
176 cnt += 1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
177 sv += v
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
178 se += e
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
179 if cnt >= step:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
180 cnt -= step
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
181 hits.addRow((d, "%.1f" % (sv/sd), "%.1f" % (se/sd)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
182 sv = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
183 se = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
184 sd = 0.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
185
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
186 table = DataBrowserWidget(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
187 table.setData(hits)
68
0bbc39b09f95 optimize backup by sorting, refactor some easy stuff to use redirectedOutput
Thomas Waldmann <tw@waldmann-edv.de>
parents: 33
diff changeset
188 return table.toHTML()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
189
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
190
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
191 def draw(pagename, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
192 import shutil, cStringIO
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
193 from MoinMoin.stats.chart import Chart, ChartData, Color
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
194
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
195 _ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
196
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
197 # check params
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
198 filterpage = None
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1866
diff changeset
199 if request and request.form and 'page' in request.form:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
200 filterpage = request.form['page'][0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
201
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
202 days, views, edits = get_data(pagename, request, filterpage)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
204 import math
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
205
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
206 try:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
207 scalefactor = float(max(views))/max(edits)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
208 except (ZeroDivisionError, ValueError):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
209 scalefactor = 1.0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
210 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
211 scalefactor = int(10 ** math.floor(math.log10(scalefactor)))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
212
1866
0194beaf511e reduce reduce, filter and map usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
213 # scale edits up
0194beaf511e reduce reduce, filter and map usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
214 edits = [x * scalefactor for x in edits]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
215
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
216 # create image
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
217 image = cStringIO.StringIO()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
218 c = Chart()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
219 c.addData(ChartData(views, color='green'))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
220 c.addData(ChartData(edits, color='red'))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
221 chart_title = ''
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
222 if request.cfg.sitename:
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
223 chart_title = "%s: " % request.cfg.sitename
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
224 chart_title = chart_title + _('Page hits and edits')
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
225 if filterpage:
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
226 chart_title = _("%(chart_title)s for %(filterpage)s") % {
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
227 'chart_title': chart_title,
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
228 'filterpage': filterpage,
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
229 }
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
230 chart_title = "%s\n%sx%d" % (chart_title, _("green=view\nred=edit"), scalefactor)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
231 c.option(
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
232 title=chart_title.encode('iso-8859-1', 'replace'), # gdchart can't do utf-8
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
233 xtitle=(_('date') + ' (Server)').encode('iso-8859-1', 'replace'),
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
234 ytitle=_('# of hits').encode('iso-8859-1', 'replace'),
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
235 title_font=c.GDC_GIANT,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
236 #thumblabel = 'THUMB', thumbnail = 1, thumbval = 10,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
237 #ytitle_color = Color('green'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
238 #yaxis2 = 1,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239 #ytitle2 = '# of edits',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
240 #ytitle2_color = Color('red'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
241 #ylabel2_color = Color('black'),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
242 #interpolations = 0,
995
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
243 threed_depth=1.0,
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
244 requested_yinterval=1.0,
b6ae650aec74 stats package whitespace-only and style cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 749
diff changeset
245 stack_type=c.GDC_STACK_BESIDE
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
246 )
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
247 c.draw(c.GDC_LINE,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
248 (request.cfg.chart_options['width'], request.cfg.chart_options['height']),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
249 image, days)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
251 headers = [
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
252 "Content-Type: image/gif",
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
253 "Content-Length: %d" % len(image.getvalue()),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
254 ]
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1017
diff changeset
255 request.emit_http_headers(headers)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
256
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
257 # copy the image
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
258 image.reset()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
259 shutil.copyfileobj(image, request, 8192)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
260