From 7f35947d8ed26690b4505f740ee9fbc73e79009a Mon Sep 17 00:00:00 2001
From: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Date: Mon, 17 Jul 2017 18:03:48 +0900
Subject: [PATCH] Improve a query in WebPushNotificationWorker (#4234)

---
 app/workers/web_push_notification_worker.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/workers/web_push_notification_worker.rb b/app/workers/web_push_notification_worker.rb
index f14efc99e1..e8f1d72bd4 100644
--- a/app/workers/web_push_notification_worker.rb
+++ b/app/workers/web_push_notification_worker.rb
@@ -9,7 +9,7 @@ class WebPushNotificationWorker
     recipient = Account.find(recipient_id)
     notification = Notification.find(notification_id)
 
-    sessions_with_subscriptions = recipient.user.session_activations.reject { |session| session.web_push_subscription.nil? }
+    sessions_with_subscriptions = recipient.user.session_activations.where.not(web_push_subscription: nil)
 
     sessions_with_subscriptions.each do |session|
       begin
-- 
GitLab