about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-05-02 22:10:57 +0200
committerGitHub <noreply@github.com>2018-05-02 22:10:57 +0200
commit658cbc94255a91453fbadd175cd45ad15efcbdf3 (patch)
treef70a7ef825bec3ff1bc3c066891e7f6df6c61370 /app/workers
parentcb5b5cb5f79bb2187d8124df91af4c8e1bfd7256 (diff)
Improve PostStatusService performance (#7317)
Offload creation of local notifications to a worker. Remove two
redundant SQL queries from ProcessMentionsService, remove n+1
XML/JSON serialization via memoization
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/local_notification_worker.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/workers/local_notification_worker.rb b/app/workers/local_notification_worker.rb
new file mode 100644
index 000000000..748270563
--- /dev/null
+++ b/app/workers/local_notification_worker.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class LocalNotificationWorker
+  include Sidekiq::Worker
+
+  def perform(mention_id)
+    mention = Mention.find(mention_id)
+    NotifyService.new.call(mention.account, mention)
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end