mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-10 01:25:15 +00:00
Fix admin setting to auto-approve hashtags not affecting query (#12130)
Follow-up to #12122
This commit is contained in:
parent
30a28a2eb7
commit
915f3712ae
|
@ -37,6 +37,7 @@ class Tag < ApplicationRecord
|
||||||
scope :pending_review, -> { unreviewed.where.not(requested_review_at: nil) }
|
scope :pending_review, -> { unreviewed.where.not(requested_review_at: nil) }
|
||||||
scope :usable, -> { where(usable: [true, nil]) }
|
scope :usable, -> { where(usable: [true, nil]) }
|
||||||
scope :listable, -> { where(listable: [true, nil]) }
|
scope :listable, -> { where(listable: [true, nil]) }
|
||||||
|
scope :trendable, -> { Setting.trendable_by_default ? where(trendable: [true, nil]) : where(trendable: true) }
|
||||||
scope :discoverable, -> { listable.joins(:account_tag_stat).where(AccountTagStat.arel_table[:accounts_count].gt(0)).order(Arel.sql('account_tag_stats.accounts_count desc')) }
|
scope :discoverable, -> { listable.joins(:account_tag_stat).where(AccountTagStat.arel_table[:accounts_count].gt(0)).order(Arel.sql('account_tag_stats.accounts_count desc')) }
|
||||||
scope :most_used, ->(account) { joins(:statuses).where(statuses: { account: account }).group(:id).order(Arel.sql('count(*) desc')) }
|
scope :most_used, ->(account) { joins(:statuses).where(statuses: { account: account }).group(:id).order(Arel.sql('count(*) desc')) }
|
||||||
scope :matches_name, ->(value) { where(arel_table[:name].matches("#{value}%")) }
|
scope :matches_name, ->(value) { where(arel_table[:name].matches("#{value}%")) }
|
||||||
|
|
|
@ -90,7 +90,7 @@ class TrendingTags
|
||||||
tag_ids = redis.zrevrange(KEY, 0, LIMIT - 1).map(&:to_i)
|
tag_ids = redis.zrevrange(KEY, 0, LIMIT - 1).map(&:to_i)
|
||||||
|
|
||||||
tags = Tag.where(id: tag_ids)
|
tags = Tag.where(id: tag_ids)
|
||||||
tags = tags.where(trendable: true) if filtered
|
tags = tags.trendable if filtered
|
||||||
tags = tags.each_with_object({}) { |tag, h| h[tag.id] = tag }
|
tags = tags.each_with_object({}) { |tag, h| h[tag.id] = tag }
|
||||||
|
|
||||||
tag_ids.map { |tag_id| tags[tag_id] }.compact.take(limit)
|
tag_ids.map { |tag_id| tags[tag_id] }.compact.take(limit)
|
||||||
|
|
Loading…
Reference in a new issue