Class: NotificationWorkers::Partner::MenuSectionsReport

Inherits:
ApplicationWorker show all
Includes:
MoneyRails::ActionViewExtension, RollbarSynTokenSetterWorker
Defined in:
app/workers/notification_workers/partner/menu_sections_report.rb

Overview

typed: true frozen_string_literal: true

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationWorker

unlimited_retry

Instance Attribute Details

#dateObject

Returns the value of attribute date.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def date
  @date
end

#date_filter_typeObject

Returns the value of attribute date_filter_type.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def date_filter_type
  @date_filter_type
end

#date_fromObject

Returns the value of attribute date_from.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def date_from
  @date_from
end

#date_toObject

Returns the value of attribute date_to.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def date_to
  @date_to
end

#emailsObject

Returns the value of attribute emails.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def emails
  @emails
end

Returns the value of attribute menu_items_ids.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def menu_items_ids
  @menu_items_ids
end

Returns the value of attribute menu_items_type.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def menu_items_type
  @menu_items_type
end

#pdf_urlObject

Returns the value of attribute pdf_url.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def pdf_url
  @pdf_url
end

#restaurant_idObject

Returns the value of attribute restaurant_id.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def restaurant_id
  @restaurant_id
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 9

def type
  @type
end

Instance Method Details

#perform(args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/workers/notification_workers/partner/menu_sections_report.rb', line 15

def perform(args)
  begin
    args.to_h.with_indifferent_access.each do |k, v|
      next if k.to_s == :use_long_process.to_s

      send("#{k}=".to_sym, v)
    end
    I18n.locale = :en
    menu_sections = collect_menu_sections
    if pdf?
      report = MenuSectionsReportPdf.new(menu_sections)
        report.generate_pdf(menu_sections, args)
        self.pdf_url = report.pdf_url
    else
      generate_menu_sections_report_to_restaurant
      self.attachment = store_to_attachment
    end
    OwnerMailer.menu_items_report(email_body, email_subject, emails).deliver_later!
  rescue StandardError => e
    APMErrorHandler.report e
    raise e
  end
end