Merge remote-tracking branch 'parent/main' into upstream-20240218
This commit is contained in:
commit
a23f77a5b8
90 changed files with 2926 additions and 2298 deletions
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::FriendsOfFriendsSource < AccountSuggestions::Source
|
||||
def get(account, limit: 10)
|
||||
def get(account, limit: DEFAULT_LIMIT)
|
||||
Account.find_by_sql([<<~SQL.squish, { id: account.id, limit: limit }]).map { |row| [row.id, key] }
|
||||
WITH first_degree AS (
|
||||
SELECT target_account_id
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::GlobalSource < AccountSuggestions::Source
|
||||
def get(account, limit: 10)
|
||||
def get(account, limit: DEFAULT_LIMIT)
|
||||
FollowRecommendation.localized(content_locale).joins(:account).merge(base_account_scope(account)).order(rank: :desc).limit(limit).pluck(:account_id, :reason)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::SettingSource < AccountSuggestions::Source
|
||||
def get(account, limit: 10)
|
||||
def get(account, limit: DEFAULT_LIMIT)
|
||||
if setting_enabled?
|
||||
base_account_scope(account).where(setting_to_where_condition).limit(limit).pluck(:id).zip([key].cycle)
|
||||
else
|
||||
|
|
|
@ -47,7 +47,7 @@ class AccountSuggestions::SimilarProfilesSource < AccountSuggestions::Source
|
|||
end
|
||||
end
|
||||
|
||||
def get(account, limit: 10)
|
||||
def get(account, limit: DEFAULT_LIMIT)
|
||||
recently_followed_account_ids = account.active_relationships.recent.limit(5).pluck(:target_account_id)
|
||||
|
||||
if Chewy.enabled? && !recently_followed_account_ids.empty?
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AccountSuggestions::Source
|
||||
DEFAULT_LIMIT = 10
|
||||
|
||||
def get(_account, **kwargs)
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
|
|
@ -101,6 +101,9 @@ class UserRole < ApplicationRecord
|
|||
before_validation :set_position
|
||||
|
||||
scope :assignable, -> { where.not(id: EVERYONE_ROLE_ID).order(position: :asc) }
|
||||
scope :highlighted, -> { where(highlighted: true) }
|
||||
scope :with_color, -> { where.not(color: [nil, '']) }
|
||||
scope :providing_styles, -> { highlighted.with_color }
|
||||
|
||||
has_many :users, inverse_of: :role, foreign_key: 'role_id', dependent: :nullify
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue