General Actions:
Log-in
Register
Wiki:
games
▼
:
Document Index
»
Space:
XWiki
▼
:
Document Index
»
Page:
Stats
Search
en
Page Actions:
Export
▼
:
Export as PDF
Export as RTF
Export as HTML
More actions
▼
:
Print preview
View Source
Stats API Demo
Wiki source code of
Stats API Demo
Last modified by
Adam Hattrell
on 2009/07/26 09:25
Content
·
Comments
(0)
·
Annotations
(0)
·
Attachments
(0)
·
History
·
Information
Show line numbers
1 Stats API Demo <% period = request.get("period") Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); if (period==null) { period = cal.get(Calendar.YEAR) * 100 + (cal.get(Calendar.MONTH)+1) } jour = cal.get(Calendar.YEAR) * 10000 + (cal.get(Calendar.MONTH)+1) * 100 + (cal.get(Calendar.DAY_OF_MONTH)+1) type = request.get("type") if (type==null) type = "view" %> 1.1 Wiki Stats [Top du Mois>${doc.name}] [Top du Jour>${doc.name}?period=${jour}] 1.1.1 Total <% sql = "select stats.name, stats.pageViews, stats.visits from DocumentStats as stats where stats.action = '${type}' and stats.name not like '%.%' and stats.period=${period} order by stats.pageViews desc" result = xwiki.search(sql, 20, 0) for (item in result) { name = item[0] nb = item[1] visits = item[2] if (name=="") { println "* Total Pages: ${nb}" println "* Total Visits: ${visits}" } else { println "* Space ${name}: ${nb}" } } %> 1.1.1 Pages <% sql = "select stats.name, stats.pageViews from DocumentStats as stats where stats.action = '${type}' and stats.name like '%.%' and stats.period=${period} order by stats.pageViews desc" result = xwiki.search(sql, 20, 0) for (item in result) { name = item[0] nb = item[1] println "* [${name}]: ${nb}" } %> 1.1 Last user connected <% sql = "select stats.name, max(stats.endDate) from VisitStats as stats group by stats.name order by 2 desc"; result = xwiki.search(sql, 100, 0) for (item in result) { user = item[0] userdate = item[1] try { userlink = xwiki.getUserName(user) } catch(Exception e) { userlink = user } println "* ${userlink}: ${userdate}" } %>