Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/stats/common.py

Issue 11481051: Update stats processing (Closed)
Patch Set: Improved performance using memoization Created Aug. 29, 2013, 1:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sitescripts/stats/bin/pagegenerator.py ('k') | sitescripts/stats/countrycodes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # coding: utf-8
2
3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2013 Eyeo GmbH
5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation.
9 #
10 # Adblock Plus is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
17
18 import re
19
20 def filename_encode(name):
21 """
22 This encodes any string to a valid file name while ensuring that the
23 original string can still be reconstructed. All characters except 0-9, A-Z,
24 the period and underscore are encoded as "-12cd" where "12cd" stands for the
25 hexadecimal representation of the character's ordinal.
26 """
27 return re.sub(r"[^\w\.]", lambda match: "-%04x" % ord(match.group(0)), name)
28
29 def filename_decode(path):
30 """
31 This reconstructs a string encoded with filename_encode().
32 """
33 return re.sub(r"-([0-9a-f]{4})", lambda match: unichr(int(match.group(1), 16)) , path)
34
35 basic_fields = [
36 {
37 "name": "day",
38 "title": "Days of month",
39 "coltitle": "Day",
40 "showaverage": True,
41 "sort": lambda obj: sorted(obj.items(), key=lambda (k,v): int(k)),
42 },
43 {
44 "name": "weekday",
45 "title": "Days of week",
46 "coltitle": "Weekday",
47 "showaverage": True,
48 "sort": lambda obj: sorted(obj.items(), key=lambda (k,v): int(k)),
49 "isspecial": lambda weekday: weekday == 5 or weekday == 6,
50 },
51 {
52 "name": "hour",
53 "title": "Hours of day",
54 "coltitle": "Hour",
55 "showaverage": True,
56 "sort": lambda obj: sorted(obj.items(), key=lambda (k,v): int(k)),
57 },
58 {
59 "name": "country",
60 "title": "Countries",
61 "coltitle": "Country",
62 },
63 {
64 "name": "ua",
65 "title": "Browsers",
66 "coltitle": "Browser",
67 },
68 {
69 "name": "fullua",
70 "title": "Browser versions",
71 "coltitle": "Browser version",
72 },
73 {
74 "name": "mirror",
75 "title": "Download mirrors",
76 "coltitle": "Download mirror",
77 },
78 ]
79
80 downloader_fields = [
81 {
82 "name": "addonName",
83 "title": "Extensions",
84 "coltitle": "Extension",
85 },
86 {
87 "name": "fullAddon",
88 "title": "Extension versions",
89 "coltitle": "Extension version",
90 },
91 {
92 "name": "application",
93 "title": "Host applications",
94 "coltitle": "Host application",
95 },
96 {
97 "name": "fullApplication",
98 "title": "Host application versions",
99 "coltitle": "Host application version",
100 },
101 {
102 "name": "platform",
103 "title": "Platforms",
104 "coltitle": "Platform",
105 },
106 {
107 "name": "fullPlatform",
108 "title": "Platform versions",
109 "coltitle": "Platform version",
110 },
111 {
112 "name": "downloadInterval",
113 "title": "Download intervals",
114 "coltitle": "Download interval",
115 },
116 {
117 "name": "firstDownload",
118 "title": "Initial download",
119 "filter": True,
120 },
121 {
122 "name": "firstInDay",
123 "title": "First download this day",
124 "filter": True,
125 },
126 {
127 "name": "firstInWeek",
128 "title": "First download this week",
129 "filter": True,
130 },
131 {
132 "name": "firstInMonth",
133 "title": "First download this month",
134 "filter": True,
135 },
136 ]
137
138 install_fields = [
139 {
140 "name": "installType",
141 "title": "Install types",
142 "coltitle": "Install type",
143 },
144 ]
145
146
147 fields = basic_fields + downloader_fields + install_fields
OLDNEW
« no previous file with comments | « sitescripts/stats/bin/pagegenerator.py ('k') | sitescripts/stats/countrycodes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld