Wiki source code of TopPageView
Last modified by Thorgal Aegirsson on 2016/03/08 18:26
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | {{velocity}} | ||
2 | |||
3 | ##Enlève les zones commentaires et autres | ||
4 | #set ($displayDocExtra = false) | ||
5 | |||
6 | #set($days = 30) | ||
7 | #if("$!request.days" != "") | ||
8 | #set($rDays = $util.parseInt($request.days)) | ||
9 | #if($rDays > 0) | ||
10 | #set($days = $rDays) | ||
11 | #end | ||
12 | #end | ||
13 | #set($top = 5) | ||
14 | #if("$!request.top" != "") | ||
15 | #set($rTop = $util.parseInt($request.top)) | ||
16 | #if($rTop > 0) | ||
17 | #set($top = $rTop) | ||
18 | #end | ||
19 | #end | ||
20 | {{html}} | ||
21 | <form method="post"> | ||
22 | <label for="days">Jours:</label> | ||
23 | <input type="text" id="days" name="days" value="$days" size="2"/> | ||
24 | <label for="top">Top:</label> | ||
25 | <input type="text" name="top" value="$top" size="3"/> | ||
26 | <input type="submit" value="Actualiser"/> | ||
27 | </form> | ||
28 | {{/html}} | ||
29 | ## | ||
30 | ## Define the scope. | ||
31 | ## | ||
32 | #set($space = "Valhalla") | ||
33 | ##set($className = "Blog.BlogPostClass") | ||
34 | ##set($scope = "select doc.fullName from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and doc.space = ? and obj.className = ?") | ||
35 | #set($scope = "select doc.fullName from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and doc.space = ? and doc.fullName != 'Valhalla.WebHome' and doc.fullName !='Valhalla.WebPreferences'") | ||
36 | |||
37 | ## | ||
38 | ## Define the period. | ||
39 | ## | ||
40 | #set($period = $xwiki.criteriaService.periodFactory.createSinceDaysPeriod($days)) | ||
41 | ## | ||
42 | ## Retrieve the stats. | ||
43 | ## | ||
44 | #set($action = "view") | ||
45 | #set($hql = "select ds.name, sum(ds.pageViews) from DocumentStats ds where ds.name in (${scope}) and ds.action = ? and ? <= ds.period and ds.period <= ? group by ds.name order by sum(ds.pageViews) desc") | ||
46 | ##set($stats = $context.xWiki.store.search($hql, $top, 0, [$space, $className, $action, $period.startCode, $period.endCode], $context.context)) | ||
47 | #set($stats = $context.xWiki.store.search($hql, $top, 0, [$space, $action, $period.startCode, $period.endCode], $context.context)) | ||
48 | ## | ||
49 | ## Display the stats. | ||
50 | ## | ||
51 | Top $top des pages les plus vues ces $days derniers jours | ||
52 | |||
53 | |=(% colspan="2" %)[[$space>>Valhalla.WebHome]]|=Hits | ||
54 | #foreach($stat in $stats) | ||
55 | |(% style="text-align:right;" %)$velocityCount|[[$stat.get(0)]]|(% style="text-align:right;" %)$stat.get(1) | ||
56 | #end | ||
57 | ## ********************Blog******************************. | ||
58 | #set($space = "Blog") | ||
59 | #set($className = "Blog.BlogPostClass") | ||
60 | #set($scope = "select doc.fullName from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and doc.space = ? and obj.className = ?") | ||
61 | #set($hql = "select ds.name, sum(ds.pageViews) from DocumentStats ds where ds.name in (${scope}) and ds.action = ? and ? <= ds.period and ds.period <= ? group by ds.name order by sum(ds.pageViews) desc") | ||
62 | #set($stats = $context.xWiki.store.search($hql, $top, 0, [$space, $className, $action, $period.startCode, $period.endCode], $context.context)) | ||
63 | ##**__Top $top des pages les plus vue de l'espace $space dans les $days derniers jours__** | ||
64 | |=(% colspan="2" %)[[$space>>Blog.WebHome]]|=Hits | ||
65 | #foreach($stat in $stats) | ||
66 | |(% style="text-align:right;" %)$velocityCount|[[$stat.get(0)]]|(% style="text-align:right;" %)$stat.get(1) | ||
67 | #end | ||
68 | ## ********************FAQ******************************. | ||
69 | #set($space = "FAQ") | ||
70 | ##set($className = "FAQ.FAQClass") | ||
71 | #set($scope = "select doc.fullName from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and doc.space = ? and doc.fullName != 'FAQ.WebHome' and doc.fullName !='FAQ.WebPreferences'") | ||
72 | #set($hql = "select ds.name, sum(ds.pageViews) from DocumentStats ds where ds.name in (${scope}) and ds.action = ? and ? <= ds.period and ds.period <= ? group by ds.name order by sum(ds.pageViews) desc") | ||
73 | #set($stats = $context.xWiki.store.search($hql, $top, 0, [$space, $action, $period.startCode, $period.endCode], $context.context)) | ||
74 | ##**__Top $top des pages les plus vue de l'espace $space dans les $days derniers jours__** | ||
75 | |=(% colspan="2" %)[[$space>>FAQ.WebHome]]|=Hits | ||
76 | #foreach($stat in $stats) | ||
77 | |(% style="text-align:right;" %)$velocityCount|[[$stat.get(0)]]|(% style="text-align:right;" %)$stat.get(1) | ||
78 | #end | ||
79 | {{/velocity}} |