Queries Library
Queries LibraryDisplay the number of comments for different periods of time

Display the number of comments for different periods of time

This query retrieves the number of comments added to the site in several periods of time:

  • in the last 24 hs
  • in the last 30 days
  • in the last year
  • since beginning of the month
  • since beginning of the year
query GetCommentsForDifferentPeriodsOfTime {
  timeNow: _time  
  time24HsAgo: _intSubtract(subtract: 86400, from: $__timeNow)
  date24HsAgo: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__time24HsAgo)  
  time1MonthAgo: _intSubtract(subtract: 2592000, from: $__timeNow)
  date1MonthAgo: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__time1MonthAgo)
  time1YearAgo: _intSubtract(subtract: 31536000, from: $__timeNow)
  date1YearAgo: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__time1YearAgo)
  timeBegOfThisMonth: _makeTime(hour: 0, minute: 0, second: 0, day: 1)
  dateBegOfThisMonth: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__timeBegOfThisMonth)
  timeBegOfThisYear: _makeTime(hour: 0, minute: 0, second: 0, month: 1, day: 1)
  dateBegOfThisYear: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__timeBegOfThisYear)
  
  commentsAddedInLast24Hs: commentCount(filter: { dateQuery: { after: $__date24HsAgo } } )  
  commentsAddedInLast1Month: commentCount(filter: { dateQuery: { after: $__date1MonthAgo } } )  
  commentsAddedInLast1Year: commentCount(filter: { dateQuery: { after: $__date1YearAgo } } )  
  commentsAddedSinceBegOfThisMonth: commentCount(filter: { dateQuery: { after: $__dateBegOfThisMonth } } )  
  commentsAddedSinceBegOfThisYear: commentCount(filter: { dateQuery: { after: $__dateBegOfThisYear } } )
}