Stats API Demo

Stats API Demo

Last modified by Administrator on 2007/07/11 16:55

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}" } %>

Tags:
Created by Administrator on 2006/12/12 23:40

Copyright 2004-2025 XWiki
4.0-milestone-1