Class: SocialRelayPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/social_relay_presenter.rb

Instance Method Summary collapse

Instance Method Details

#add_user_tags(tags) ⇒ Object


19
20
21
22
23
24
25
# File 'app/presenters/social_relay_presenter.rb', line 19

def add_user_tags(tags)
  if AppConfig.relay.inbound.include_user_tags?
    user_ids = User.halfyear_actives.pluck(:id)
    tag_ids = TagFollowing.where(user: user_ids).select(:tag_id).distinct.pluck(:tag_id)
    tags.concat ActsAsTaggableOn::Tag.where(id: tag_ids).pluck(:name)
  end
end

#as_jsonObject


4
5
6
7
8
9
10
# File 'app/presenters/social_relay_presenter.rb', line 4

def as_json(*)
  {
    "subscribe" => AppConfig.relay.inbound.subscribe?,
    "scope"     => AppConfig.relay.inbound.scope,
    "tags"      => tags
  }
end

#tagsObject


12
13
14
15
16
17
# File 'app/presenters/social_relay_presenter.rb', line 12

def tags
  return [] unless AppConfig.relay.inbound.scope == "tags"
  tags = AppConfig.relay.inbound.pod_tags.present? ? AppConfig.relay.inbound.pod_tags.split(",").map(&:strip) : []
  add_user_tags(tags)
  tags.uniq
end