Class: Resque::Reports::ReportJob

Inherits:
Object
  • Object
show all
Extended by:
Extensions::EnqueueToFix
Includes:
Integration
Defined in:
app/jobs/resque/reports/report_job.rb

Overview

ReportJob accepts report_type, its arguments in json and building report in background @example:

ReportJob.enqueue('Resque::Reports::MyReport', [1, 2].to_json)
ReportJob.enqueue_to(:my_queue, 'Resque::Reports::MyReport', [1, 2].to_json)

Class Method Summary collapse

Methods included from Extensions::EnqueueToFix

extended

Class Method Details

.execute(report_type, args_json) ⇒ Object

resque-integration main job method

Parameters:

  • report_type (String)
    • name of BaseReport successor

    to build report for

  • args_json (String(JSON))
    • json array of report arguments



24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/jobs/resque/reports/report_job.rb', line 24

def self.execute(report_type, args_json)
  report_class = report_type.constantize # избавиться от ActiveSupport

  unless report_class < BaseReport
    fail "Supports only successors of BaseReport, but got #{report_class}"
  end

  args = JSON.parse(args_json)
  force = args.pop

  init_report(report_class, args).build(force)
end