FIX: n+1 query on list of private messages assigned (#216)

FIX: n+1 query on list of private messages assigned (#216)

When getting a list of private messages assigned to groups/users, we should include :allowed_users to avoid n+1

diff --git a/plugin.rb b/plugin.rb
index 2d87958..8ed9e50 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -294,7 +294,7 @@ after_initialize do
 
     sql = "topics.id IN (#{topic_ids_sql})"
 
-    list = list.where(sql, user_id: user.id)
+    list = list.where(sql, user_id: user.id).includes(:allowed_users)
 
     create_list(:assigned, { unordered: true }, list)
   end
@@ -319,7 +319,7 @@ after_initialize do
 
     sql = "topics.id IN (#{topic_ids_sql})"
 
-    list = list.where(sql, group_id: group.id)
+    list = list.where(sql, group_id: group.id).includes(:allowed_users)
 
     create_list(:assigned, { unordered: true }, list)
   end

GitHub sha: 3a58df219ca191e56723f9f774c36dd3dce770a8

This commit appears in #216 which was approved by tgxworld. It was merged by tgxworld.