Class: Decidim::Follow

Inherits:
ApplicationRecord show all
Includes:
DataPortability
Defined in:
decidim-core/app/models/decidim/follow.rb

Class Method Summary collapse

Class Method Details

.export_serializerObject


22
23
24
# File 'decidim-core/app/models/decidim/follow.rb', line 22

def self.export_serializer
  Decidim::DataPortabilitySerializers::DataPortabilityFollowSerializer
end

.user_collection(user) ⇒ Object


18
19
20
# File 'decidim-core/app/models/decidim/follow.rb', line 18

def self.user_collection(user)
  where(decidim_user_id: user.id)
end

.user_follower_ids_for_participatory_spaces(spaces) ⇒ Object


26
27
28
29
30
# File 'decidim-core/app/models/decidim/follow.rb', line 26

def self.user_follower_ids_for_participatory_spaces(spaces)
  # IF the space has questions it's a Consultations
  followables = spaces.flat_map { |space| space.try(:questions) || space }
  joins(:user).where(followable: followables).pluck(:decidim_user_id).uniq
end