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" %>Wiki Stats Top du Mois Top du Jour
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 = item0? nb = item1? visits = item2? if (name=="") { println "* Total Pages: ${nb}" println "* Total Visits: ${visits}" } else { println "* Space ${name}: ${nb}" } } %>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 = item0? nb = item1? println "* ${name}?: ${nb}" } %>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 = item0? userdate = item1? try { userlink = xwiki.getUserName(user) } catch(Exception e) { userlink = user } println "* ${userlink}: ${userdate}" } %>
Version 2.1 last modified by Lucien Pereira on 01/08/2008 at 15:07
Document data
Attachments:
No attachments for this document
Comments: 0