]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/analytics.py
7 from . import ui_modules
9 class IndexHandler(base
.BaseHandler
):
10 @tornado.web
.authenticated
12 # Check access permissions
13 if not self
.current_user
.is_admin():
14 raise tornado
.web
.HTTPError(403)
16 self
.render("analytics/index.html")
19 class DocsHandler(base
.BaseHandler
):
20 @tornado.web
.authenticated
22 # Check access permissions
23 if not self
.current_user
.is_admin():
24 raise tornado
.web
.HTTPError(403)
27 popular_pages
= self
.backend
.analytics
.get_most_popular_docs_pages(
28 self
.request
.host
, since
=datetime
.timedelta(hours
=24 * 365), limit
=50)
31 popular_searches
= self
.backend
.analytics
.get_search_queries(
32 self
.request
.host
, "/docs/search", limit
=25)
34 self
.render("analytics/docs.html",
35 popular_pages
=popular_pages
, popular_searches
=popular_searches
)
38 class SummaryModule(ui_modules
.UIModule
):
39 def render(self
, host
=None, uri
=None):
41 host
= self
.request
.host
44 uri
= self
.request
.path
46 # Fetch the total number of page views
47 total_page_views
= self
.backend
.analytics
.get_page_views(host
, uri
)
49 # Fetch the total number of page views in the last 24h
50 total_page_views_24h
= self
.backend
.analytics
.get_page_views(host
, uri
,
51 since
=datetime
.timedelta(hours
=24))
53 return self
.render_string("analytics/modules/summary.html", host
=host
, uri
=uri
,
54 total_page_views
=total_page_views
, total_page_views_24h
=total_page_views_24h
)