From 27d7b0c6de73cb0cd2bd5137b5a58c151bd83289 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Tue, 7 Jun 2022 12:58:58 -0600 Subject: [PATCH] DEV: Add new user scopes (#17026) Adds two new user scopes: - `not_staged` - `activated_not_suspended_not_staged` This will allow us to easily grab activated users that are not suspended or staged. See this PR feedback: https://github.com/discourse/discourse-chat/pull/913#discussion_r890692266 --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index d2e3323f3fb..92ae57dd0a9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -220,6 +220,8 @@ class User < ActiveRecord::Base scope :suspended, -> { where('suspended_till IS NOT NULL AND suspended_till > ?', Time.zone.now) } scope :not_suspended, -> { where('suspended_till IS NULL OR suspended_till <= ?', Time.zone.now) } scope :activated, -> { where(active: true) } + scope :not_staged, -> { where(staged: false) } + scope :activated_not_suspended_not_staged, -> { self.activated.not_suspended.not_staged } scope :filter_by_username, ->(filter) do if filter.is_a?(Array)