Number Of Created Articles Per Day And Per Week

Last modified by Vincent Massol on 2013/03/11 09:38

chart_lineStatistics about created articles over time
Developed by

xwiki:XWiki.mflorea

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Shows how the number of created articles changes over time, per day or per week. Articles that were deleted are not included. This code must be saved with programming rights because the search is done using protected API.

{{velocity}}
= Per Day =

##
## Define the period.
##
#set($days = 7)
#set($period = $xwiki.criteriaService.periodFactory.createSinceDaysPeriod($days))
#set($startDate = $util.getDate($xwiki.criteriaService.periodFactory.createDayPeriod($period.start).start))
#set($endDate = $util.getDate($xwiki.criteriaService.periodFactory.createDayPeriod($period.end).end))
##
## Retrieve the stats.
##
#set($space = "Blog")
#set($className = "Blog.BlogPostClass")
#set($hql = "select year(doc.creationDate), month(doc.creationDate), day(doc.creationDate), count(*) from XWikiDocument doc, BaseObject obj where doc.space = ? and doc.fullName = obj.name and obj.className = ? and ? <= doc.creationDate and doc.creationDate < ? group by year(doc.creationDate), month(doc.creationDate), day(doc.creationDate) order by year(doc.creationDate), month(doc.creationDate), day(doc.creationDate)")
#set($stats = $context.xWiki.store.search($hql, $days, 0, [$space, $className, $startDate, $endDate], $context.context))
##
## Display the stats.
##
|=Year|=Month|=Day|=Number of created pages
#foreach($stat in $stats)
#foreach($part in $stat)|(% style="text-align:right" %)$part#end

#end

= Per Week =

##
## Define the period.
##
#set($weeks = 4)
#set($period = $xwiki.criteriaService.periodFactory.createSinceWeeksPeriod($weeks))
#set($startDate = $util.getDate($xwiki.criteriaService.periodFactory.createWeekPeriod($period.start).start))
#set($endDate = $util.getDate($xwiki.criteriaService.periodFactory.createWeekPeriod($period.end).end))
##
## Retrieve the stats.
##
#set($hql = "select year(doc.creationDate), week(doc.creationDate), count(*) from XWikiDocument doc, BaseObject obj where doc.space = ? and doc.fullName = obj.name and obj.className = ? and ? <= doc.creationDate and doc.creationDate < ? group by year(doc.creationDate), week(doc.creationDate) order by year(doc.creationDate), week(doc.creationDate)")
#set($stats = $context.xWiki.store.search($hql, $weeks, 0, [$space, $className, $startDate, $endDate], $context.context))
##
## Display the stats.
##
|=Year|=Week|=Number of created pages
#foreach($stat in $stats)
#foreach($part in $stat)|(% style="text-align:right" %)$part#end

#end
{{/velocity}}

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags: statistics
     

Get Connected