about summary refs log tree commit diff
path: root/app/presenters/tag_relationships_presenter.rb
blob: 52e24314be23f543494ebc4dbd955843a35825f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
# frozen_string_literal: true

class TagRelationshipsPresenter
  attr_reader :following_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
  end
end