Class: PartnerService::ReportProgress
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- PartnerService::ReportProgress
- Defined in:
- app/services/partner_service/report_progress.rb
Overview
This class is responsible for reporting progress of various types of reports.
Instance Attribute Summary collapse
-
#args ⇒ Object
Returns the value of attribute args.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from ApplicationService
Class Method Summary collapse
-
.generate_name(type, args) ⇒ String
Generates a unique name for the report.
Instance Method Summary collapse
-
#export ⇒ String
Exports the report and returns the job ID.
-
#initialize(type, args) ⇒ ReportProgress
constructor
Initializes a new instance of ReportProgress.
Methods inherited from ApplicationService
Constructor Details
#initialize(type, args) ⇒ ReportProgress
Initializes a new instance of ReportProgress.
13 14 15 16 |
# File 'app/services/partner_service/report_progress.rb', line 13 def initialize(type, args) @type = type @args = args end |
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
7 8 9 |
# File 'app/services/partner_service/report_progress.rb', line 7 def args @args end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'app/services/partner_service/report_progress.rb', line 7 def type @type end |
Class Method Details
.generate_name(type, args) ⇒ String
Generates a unique name for the report.
67 68 69 |
# File 'app/services/partner_service/report_progress.rb', line 67 def self.generate_name(type, args) "Report_#{type}_#{args[:type]}_#{SecureRandom.hex(3)}" end |
Instance Method Details
#export ⇒ String
Exports the report and returns the job ID.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/services/partner_service/report_progress.rb', line 21 def export = Attachment.create( restaurant_id: args[:restaurant_id], exported_by: :owner_staff, report_type: type, status: :on_queue, name: PartnerService::ReportProgress.generate_name(type, args), ) job_id = run_worker(.id) if .present? && .persisted? .job_id = job_id .save! end job_id end |