From 33d227d5dd3f314c2193c9c1984ea02552c47b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Salvador=20P=C3=A9rez=20Garc=C3=ADa?= Date: Wed, 4 Jul 2018 08:19:04 +0200 Subject: [PATCH] Proposal community Poll participants become automatically members of the proposal community --- app/models/community.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/community.rb b/app/models/community.rb index c9dd0ddfb..fb3e5dc7c 100644 --- a/app/models/community.rb +++ b/app/models/community.rb @@ -6,6 +6,7 @@ class Community < ActiveRecord::Base def participants users_participants = users_who_commented + users_who_topics_author + + response_author_from_polls_for_proposal + author_from_community users_participants.uniq end @@ -31,4 +32,13 @@ class Community < ActiveRecord::Base from_proposal? ? User.where(id: proposal&.author_id) : User.where(id: investment&.author_id) end + def response_author_from_polls_for_proposal + author_ids = [] + + Poll.where(related: proposal).each do |poll| + author_ids += poll.questions.pluck(:author_id) + end + + User.by_authors(author_ids.uniq) + end end