allura
Revision | 378a7e63cf1c6e0a5168b8621356901b322f5cdc (tree) |
---|---|
Zeit | 2012-04-20 05:54:22 |
Autor | bolkimen <bolkimen@yaho...> |
Commiter | Yaroslav Luzin |
ticket:17 add stats page
@@ -1,7 +1,8 @@ | ||
1 | 1 | import logging |
2 | 2 | from collections import defaultdict |
3 | -from datetime import datetime | |
3 | +from datetime import datetime, timedelta | |
4 | 4 | |
5 | +import Image | |
5 | 6 | import pkg_resources |
6 | 7 | from pylons import c, g, request |
7 | 8 | from paste.deploy.converters import asbool |
@@ -138,6 +139,7 @@ class AdminApp(Application): | ||
138 | 139 | links.append(SitemapEntry('Invitation(s)', admin_url+'invitations')) |
139 | 140 | links.append(SitemapEntry('Audit Trail', admin_url+ 'audit/')) |
140 | 141 | if c.project.shortname == '--init--': |
142 | + links.append(SitemapEntry('Statistics', nbhd_admin_url+ 'stats/')) | |
141 | 143 | links.append(None) |
142 | 144 | links.append(SitemapEntry('Help', nbhd_admin_url+ 'help/')) |
143 | 145 | return links |
@@ -212,6 +214,47 @@ class ProjectAdminController(BaseController): | ||
212 | 214 | roles=M.ProjectRole.query.find(dict(project_id=c.project.root_project._id)).sort('_id').all(), |
213 | 215 | categories=M.ProjectCategory.query.find(dict(parent_id=None)).sort('label').all()) |
214 | 216 | |
217 | + @without_trailing_slash | |
218 | + @expose('jinja:allura.ext.admin:templates/project_stats.html') | |
219 | + def stats(self, **kw): | |
220 | + if c.project.shortname != '--init--': | |
221 | + redirect('index') | |
222 | + | |
223 | + # public private deleted | |
224 | + delete_count = M.Project.query.find(dict(neighborhood_id=c.project.neighborhood._id, deleted=True)).count() | |
225 | + public_count = 0 | |
226 | + private_count = 0 | |
227 | + last_updated_30 = 0 | |
228 | + last_updated_60 = 0 | |
229 | + last_updated_90 = 0 | |
230 | + today_date = datetime.today() | |
231 | + for p in M.Project.query.find(dict(neighborhood_id=c.project.neighborhood._id, deleted=False)).all(): | |
232 | + if p.private: | |
233 | + private_count = private_count + 1 | |
234 | + else: | |
235 | + public_count = public_count + 1 | |
236 | + if today_date - p.last_updated < timedelta(days=30): | |
237 | + last_updated_30 = last_updated_30 + 1 | |
238 | + if today_date - p.last_updated < timedelta(days=60): | |
239 | + last_updated_60 = last_updated_60 + 1 | |
240 | + if today_date - p.last_updated < timedelta(days=90): | |
241 | + last_updated_90 = last_updated_90 + 1 | |
242 | + | |
243 | + c.delete_count = delete_count | |
244 | + c.public_count = public_count | |
245 | + c.private_count = private_count | |
246 | + c.last_updated_30 = last_updated_30 | |
247 | + c.last_updated_60 = last_updated_60 | |
248 | + c.last_updated_90 = last_updated_90 | |
249 | + | |
250 | + c.markdown_editor = W.markdown_editor | |
251 | + c.label_edit = W.label_edit | |
252 | + c.mount_delete = W.mount_delete | |
253 | + c.admin_modal = W.admin_modal | |
254 | + c.install_modal = W.install_modal | |
255 | + mounts = c.project.ordered_mounts() | |
256 | + return dict() | |
257 | + | |
215 | 258 | @expose() |
216 | 259 | @require_post() |
217 | 260 | def update_labels(self, labels=None, labels_old=None, **kw): |
@@ -0,0 +1,38 @@ | ||
1 | +{% extends g.theme.master %} | |
2 | + | |
3 | +{% do g.register_forge_css('css/forge/deck.css') %} | |
4 | + | |
5 | +{% block title %}{{c.project.name}} / Statistics{% endblock %} | |
6 | + | |
7 | +{% block header %}Statistics{% endblock %} | |
8 | + | |
9 | +{% block content %} | |
10 | + <h3>Neighborhood statistics</h3> | |
11 | + <div class="nested-grid-container"> | |
12 | + <span class="grid-prefix-1 grid-9 installable_tool"> | |
13 | + <b>Projects</b> | |
14 | + </span> | |
15 | + <span class="grid-9 installable_tool"> | |
16 | + <b>Last updated</b> | |
17 | + </span> | |
18 | + <span class="grid-prefix-1 grid-9 installable_tool"> | |
19 | + Deleted: {{ c.delete_count }} | |
20 | + </span> | |
21 | + <span class="grid-9 installable_tool"> | |
22 | + Last 30 days: {{ c.last_updated_30 }} | |
23 | + </span> | |
24 | + <span class="grid-prefix-1 grid-9 installable_tool"> | |
25 | + Public: {{ c.public_count }} | |
26 | + </span> | |
27 | + <span class="grid-9 installable_tool"> | |
28 | + Last 60 days: {{ c.last_updated_60 }} | |
29 | + </span> | |
30 | + <span class="grid-prefix-1 grid-9 installable_tool"> | |
31 | + Private: {{ c.private_count }} | |
32 | + </span> | |
33 | + <span class=" grid-9 installable_tool"> | |
34 | + Last 90 days: {{ c.last_updated_90 }} | |
35 | + </span> | |
36 | + </div> | |
37 | + | |
38 | +{% endblock %} |