Add trending statuses (#17431)
* Add trending statuses * Fix dangling items with stale scores in localized sets * Various fixes and improvements - Change approve_all/reject_all to approve_accounts/reject_accounts - Change Trends::Query methods to not mutate the original query - Change Trends::Query#skip to offset - Change follow recommendations to be refreshed in a transaction * Add tests for trending statuses filtering behaviour * Fix not applying filtering scope in controller
This commit is contained in:
parent
a29a982eaa
commit
27965ce5ed
71 changed files with 1074 additions and 307 deletions
|
@ -13,15 +13,37 @@ module Trends
|
|||
@tags ||= Trends::Tags.new
|
||||
end
|
||||
|
||||
def self.statuses
|
||||
@statuses ||= Trends::Statuses.new
|
||||
end
|
||||
|
||||
def self.register!(status)
|
||||
[links, tags, statuses].each { |trend_type| trend_type.register(status) }
|
||||
end
|
||||
|
||||
def self.refresh!
|
||||
[links, tags].each(&:refresh)
|
||||
[links, tags, statuses].each(&:refresh)
|
||||
end
|
||||
|
||||
def self.request_review!
|
||||
[links, tags].each(&:request_review) if enabled?
|
||||
return unless enabled?
|
||||
|
||||
links_requiring_review = links.request_review
|
||||
tags_requiring_review = tags.request_review
|
||||
statuses_requiring_review = statuses.request_review
|
||||
|
||||
return if links_requiring_review.empty? && tags_requiring_review.empty? && statuses_requiring_review.empty?
|
||||
|
||||
User.staff.includes(:account).find_each do |user|
|
||||
AdminMailer.new_trends(user.account, links_requiring_review, tags_requiring_review, statuses_requiring_review).deliver_later! if user.allows_trends_review_emails?
|
||||
end
|
||||
end
|
||||
|
||||
def self.enabled?
|
||||
Setting.trends
|
||||
end
|
||||
|
||||
def self.available_locales
|
||||
@available_locales ||= I18n.available_locales.map { |locale| locale.to_s.split(/[_-]/).first }.uniq
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue