cogStatistics about deleted articles over time
Developed by

Marius Dumitru Florea

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Shows how the number of deleted articles changes over time, per day or per week. Only pages from recycle bin are counted. This code must be saved with programming rights because the query is executed 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(ddoc.date), month(ddoc.date), day(ddoc.date), count(*) from XWikiDeletedDocument ddoc where ddoc.fullName like ?||'.%' and ? <= ddoc.date and ddoc.date < ? and ddoc.xml like '%<className>'||?||'</className>%' group by year(ddoc.date), month(ddoc.date), day(ddoc.date) order by year(ddoc.date), month(ddoc.date), day(ddoc.date)")
#set($stats = $context.xWiki.store.search($hql, $days, 0, [$space, $startDate, $endDate, $className], $context.context))
##
## Display the stats.
##
|=Year|=Month|=Day|=Number of deleted 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(ddoc.date), week(ddoc.date), count(*) from XWikiDeletedDocument ddoc where ddoc.fullName like ?||'.%' and ? <= ddoc.date and ddoc.date < ? and ddoc.xml like '%<className>'||?||'</className>%' group by year(ddoc.date), week(ddoc.date) order by year(ddoc.date), week(ddoc.date)")
#set($stats = $context.xWiki.store.search($hql, $weeks, 0, [$space, $startDate, $endDate, $className], $context.context))
##
## Display the stats.
##
|=Year|=Week|=Number of deleted 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
Created by Marius Dumitru Florea on 2010/03/09 15:41
     

Get Connected