This repository has been archived on 2024-07-31. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-12 06:37:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class FollowRecommendationFilter
|
2022-04-28 11:47:34 -04:00
|
|
|
include Redisable
|
|
|
|
|
2021-04-12 06:37:14 -04:00
|
|
|
KEYS = %i(
|
|
|
|
language
|
|
|
|
status
|
|
|
|
).freeze
|
|
|
|
|
|
|
|
attr_reader :params, :language
|
|
|
|
|
|
|
|
def initialize(params)
|
|
|
|
@language = params.delete('language') || I18n.locale
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def results
|
|
|
|
if params['status'] == 'suppressed'
|
2023-12-19 05:59:43 -05:00
|
|
|
Account.includes(:account_stat).joins(:follow_recommendation_suppression).order(FollowRecommendationSuppression.arel_table[:id].desc)
|
2021-04-12 06:37:14 -04:00
|
|
|
else
|
2023-12-19 05:59:43 -05:00
|
|
|
Account.includes(:account_stat).joins(:follow_recommendation).merge(FollowRecommendation.localized(@language).order(rank: :desc))
|
2021-04-12 06:37:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|