From 658cbc94255a91453fbadd175cd45ad15efcbdf3 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 2 May 2018 22:10:57 +0200 Subject: 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 --- app/workers/local_notification_worker.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/workers/local_notification_worker.rb (limited to 'app/workers') 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 -- cgit