Display the number of comments for different periods of time

🔥 This query is already included in Gato GraphQL, as Persisted Query “Fetch comments by period”.

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: _intSubstract(substract: 86400, from: $__timeNow)
date24HsAgo: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__time24HsAgo)
time1MonthAgo: _intSubstract(substract: 2592000, from: $__timeNow)
date1MonthAgo: _date(format: "Y-m-d\\TH:i:sO", timestamp: $__time1MonthAgo)
time1YearAgo: _intSubstract(substract: 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 } } )

Extensions required for this query permalink

  1. Field To Input permalink

    Retrieve the value of a field, manipulate it, and input it into another field or directive, all within the same operation.

  2. PHP Constants and Environment Variables via Schema permalink

    Query the value from an environment variable or PHP constant.

  3. PHP Functions via Schema permalink

    Manipulate the field output using standard programming language functions available in PHP.

Bundles containing all extensions required for this query permalink

  1. “All in One Toolbox for WordPress” Bundle permalink

    Achieve all superpowers: All of Gato GraphQL extensions, in a single plugin

  2. “Automated Content Translation & Sync for WordPress Multisite” Bundle permalink

    Automatically create a translation of a newly-published post using the Google Translate API, for every language site on a WordPress multisite

  3. “Better WordPress Webhooks” Bundle permalink

    Easily create webhooks to process incoming data from any source or service using advanced tools, directly within the wp-admin

  4. “Private GraphQL Server for WordPress” Bundle permalink

    Use GraphQL to power your application (blocks, themes and plugins), internally fetching data without exposing a public endpoint

  5. “Selective Content Import, Export & Sync for WordPress” Bundle permalink

    Import hundreds of records into your WordPress site from another site or service (such as Google Sheets), and selectively export entries to another site

  6. “Tailored WordPress Automator” Bundle permalink

    Create workflows to automate tasks (to transform data, automatically caption images, send notifications, and more)

  7. “Unhindered WordPress Email Notifications” Bundle permalink

    Send personalized emails to all your users, and notifications to the admin, without constraints on what data can be added to the email

  8. “Versatile WordPress Request API” Bundle permalink

    Interact with any external API and cloud service, posting and fetching data to/from them

Tutorial lessons explaining how the query works permalink