Sha256: 1db7d1cc572478c7214ab565617e6cd9eeb8750357898d679bb90623650aca6d

Contents?: true

Size: 772 Bytes

Versions: 25

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

module Decidim
  # This query counts registered users from a collection of organizations
  # in an optional interval of time.
  class StatsUsersCount < Decidim::Query
    def self.for(organization, start_at = nil, end_at = nil)
      new(organization, start_at, end_at).query
    end

    def initialize(organization, start_at = nil, end_at = nil)
      @organization = organization
      @start_at = start_at
      @end_at = end_at
    end

    def query
      users = Decidim::User.where(organization: @organization).not_deleted.not_blocked.confirmed
      users = users.where("created_at >= ?", @start_at) if @start_at.present?
      users = users.where("created_at <= ?", @end_at) if @end_at.present?
      users.count
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.4 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.9 app/queries/decidim/stats_users_count.rb
decidim-core-0.29.0 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.3 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.8 app/queries/decidim/stats_users_count.rb
decidim-core-0.29.0.rc4 app/queries/decidim/stats_users_count.rb
decidim-core-0.29.0.rc3 app/queries/decidim/stats_users_count.rb
decidim-core-0.29.0.rc2 app/queries/decidim/stats_users_count.rb
decidim-core-0.29.0.rc1 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.2 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.7 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.1 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.6 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.0 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.5 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.0.rc5 app/queries/decidim/stats_users_count.rb
decidim-core-0.28.0.rc4 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.4 app/queries/decidim/stats_users_count.rb
decidim-core-0.27.3 app/queries/decidim/stats_users_count.rb