0
0
Fork 0

Add not_featured_by scope to Tag (#28815)

This commit is contained in:
Matt Jankowski 2024-04-17 06:05:38 -04:00 committed by GitHub
parent 1d3ecd3fba
commit 650c548c31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 6 deletions

View file

@ -53,6 +53,8 @@ class Tag < ApplicationRecord
scope :listable, -> { where(listable: [true, nil]) }
scope :trendable, -> { Setting.trendable_by_default ? where(trendable: [true, nil]) : where(trendable: true) }
scope :not_trendable, -> { where(trendable: false) }
scope :suggestions_for_account, ->(account) { recently_used(account).not_featured_by(account) }
scope :not_featured_by, ->(account) { where.not(id: account.featured_tags.select(:tag_id)) }
scope :recently_used, lambda { |account|
joins(:statuses)
.where(statuses: { id: account.statuses.select(:id).limit(RECENT_STATUS_LIMIT) })