Add Account.without_internal scope (#29559)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Matt Jankowski 2024-03-13 10:11:23 -04:00 committed by GitHub
parent acf3f410ae
commit c09b8a7164
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 6 deletions

View file

@ -129,7 +129,7 @@ class ApplicationController < ActionController::Base
end
def single_user_mode?
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.where('id > 0').exists?
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.without_internal.exists?
end
def use_seamless_external_login?

View file

@ -213,7 +213,7 @@ module ApplicationHelper
state_params[:moved_to_account] = current_account.moved_to_account
end
state_params[:owner] = Account.local.without_suspended.where('id > 0').first if single_user_mode?
state_params[:owner] = Account.local.without_suspended.without_internal.first if single_user_mode?
json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json
# rubocop:disable Rails/OutputSafety

View file

@ -111,6 +111,7 @@ class Account < ApplicationRecord
normalizes :username, with: ->(username) { username.squish }
scope :without_internal, -> { where(id: 1...) }
scope :remote, -> { where.not(domain: nil) }
scope :local, -> { where(domain: nil) }
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }