Number of Deleted Articles Per Day And Per Week
Last modified by Vincent Massol on 2021/03/18 11:28
Statistics about deleted articles over time |
Type | Snippet |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
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}}
= 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}}