Sha256: f7e0465371a6d0418a4fa0760b0d203f7b9b4f1d3a20a8cb61bfcf3c87b059eb
Contents?: true
Size: 772 Bytes
Versions: 19
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 < Rectify::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
19 entries across 19 versions & 1 rubygems