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
This commit is contained in:
Blake Erickson 2022-06-07 12:58:58 -06:00 committed by GitHub
parent de1153286d
commit 27d7b0c6de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -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)