Refactor and tests.

This commit is contained in:
taitus
2017-08-10 15:02:02 +02:00
parent 555c47e012
commit 4539c5fa00
36 changed files with 1023 additions and 110 deletions

View File

@@ -315,7 +315,13 @@ class User < ActiveRecord::Base
def self.community_participants(community)
topics_ids = community.topics.pluck(:id)
User.joins(:comments).where("comments.commentable_id IN (?) and comments.commentable_type = 'Topic'", topics_ids)
users_who_commented = User.joins(:comments).where("comments.commentable_id IN (?) and comments.commentable_type = 'Topic'", topics_ids).uniq
author_ids = community.topics.pluck(:author_id)
users_who_authors = User.where("users.id IN (?)", author_ids)
users_participants = users_who_commented + users_who_authors
users_participants.uniq
end
private