Add REST API for featuring and unfeaturing a hashtag (#34489)
Co-authored-by: Matt Jankowski <matt@jankowski.online> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
49b6a49c76
commit
a97647158c
15 changed files with 195 additions and 50 deletions
|
@ -1,13 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TagRelationshipsPresenter
|
||||
attr_reader :following_map
|
||||
attr_reader :following_map, :featuring_map
|
||||
|
||||
def initialize(tags, current_account_id = nil, **options)
|
||||
@following_map = if current_account_id.nil?
|
||||
{}
|
||||
else
|
||||
TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
|
||||
end
|
||||
if current_account_id.nil?
|
||||
@following_map = {}
|
||||
@featuring_map = {}
|
||||
else
|
||||
@following_map = TagFollow.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:following_map] || {})
|
||||
@featuring_map = FeaturedTag.select(:tag_id).where(tag_id: tags.map(&:id), account_id: current_account_id).each_with_object({}) { |f, h| h[f.tag_id] = true }.merge(options[:featuring_map] || {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue