From a13d2443bd84ed0e008add88ddee5f0aba602bc4 Mon Sep 17 00:00:00 2001 From: Georg G Date: Tue, 5 Jan 2016 20:54:00 +0100 Subject: [PATCH] added ExportWorker --- app/workers/export_worker.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/workers/export_worker.rb diff --git a/app/workers/export_worker.rb b/app/workers/export_worker.rb new file mode 100644 index 00000000..29d95dc3 --- /dev/null +++ b/app/workers/export_worker.rb @@ -0,0 +1,16 @@ +require 'exporter' +class ExportWorker + include Sidekiq::Worker + + sidekiq_options queue: :export, retry: false + + # @param user_id [Integer] the user id + def perform(user_id) + exporter = Exporter.new User.find(user_id) + exporter.export + question = Question.create(content: "Your #{APP_CONFIG['site_name']} data export is ready! You can download it " + + "from the settings page under the \"Export\" tab.", author_is_anonymous: true, + author_name: "retrospring_exporter") + Inbox.create(user_id: user_id, question_id: question.id, new: true) + end +end