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
Hide line numbers
1: 1 Stats API Demo 2: 3: <% 4: period = request.get("period") 5: Calendar cal = Calendar.getInstance(); 6: cal.setTime(new Date()); 7: if (period==null) { 8: period = cal.get(Calendar.YEAR) * 100 + (cal.get(Calendar.MONTH)+1) 9: } 10: 11: jour = cal.get(Calendar.YEAR) * 10000 + (cal.get(Calendar.MONTH)+1) * 100 + (cal.get(Calendar.DAY_OF_MONTH)+1) 12: 13: type = request.get("type") 14: if (type==null) 15: type = "view" 16: 17: %> 18: 19: 1.1 Wiki Stats [Top du Mois>${doc.name}] [Top du Jour>${doc.name}?period=${jour}] 20: 21: 1.1.1 Total 22: 23: <% 24: 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" 25: result = xwiki.search(sql, 20, 0) 26: 27: for (item in result) { 28: name = item[0] 29: nb = item[1] 30: visits = item[2] 31: if (name=="") { 32: println "* Total Pages: ${nb}" 33: println "* Total Visits: ${visits}" 34: } 35: else { 36: println "* Space ${name}: ${nb}" 37: } 38: } 39: %> 40: 41: 42: 1.1.1 Pages 43: <% 44: 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" 45: result = xwiki.search(sql, 20, 0) 46: 47: for (item in result) { 48: name = item[0] 49: nb = item[1] 50: println "* [${name}]: ${nb}" 51: } 52: %> 53: 54: 1.1 Last user connected 55: 56: <% 57: 58: sql = "select stats.name, max(stats.endDate) from VisitStats as stats group by stats.name order by 2 desc"; 59: result = xwiki.search(sql, 100, 0) 60: 61: for (item in result) { 62: user = item[0] 63: userdate = item[1] 64: try { 65: userlink = xwiki.getUserName(user) 66: } catch(Exception e) { 67: userlink = user 68: } 69: println "* ${userlink}: ${userdate}" 70: } 71: %>