Commit 824666dd846e84f4cbe5a17676bc5f763245b122

Authored by Victor Costa
1 parent ea7e701a
Exists in master

Fix jobs

controllers/myprofile/dialoga_plugin_myprofile_controller.rb
@@ -4,7 +4,8 @@ class DialogaPluginMyprofileController < MyProfileController @@ -4,7 +4,8 @@ class DialogaPluginMyprofileController < MyProfileController
4 before_filter :is_admin 4 before_filter :is_admin
5 5
6 def send_report 6 def send_report
7 - report_path = Time.zone.now.strftime('%Y-%m-%d-%H-%m-%S') 7 + report_path = Time.zone.now.strftime('%Y-%m-%d-%H-%M-%S')
  8 + DialogaPlugin::ReportJob.create_report_path(profile, report_path)
8 Delayed::Job.enqueue(DialogaPlugin::ReportJob.new(profile.id, report_path)) 9 Delayed::Job.enqueue(DialogaPlugin::ReportJob.new(profile.id, report_path))
9 Delayed::Job.enqueue(DialogaPlugin::RankingJob.new(profile.id, report_path)) 10 Delayed::Job.enqueue(DialogaPlugin::RankingJob.new(profile.id, report_path))
10 Delayed::Job.enqueue(DialogaPlugin::EventJob.new(profile.id, report_path)) 11 Delayed::Job.enqueue(DialogaPlugin::EventJob.new(profile.id, report_path))
lib/dialoga_plugin/event_job.rb
@@ -3,7 +3,7 @@ class DialogaPlugin::EventJob < DialogaPlugin::ReportJob @@ -3,7 +3,7 @@ class DialogaPlugin::EventJob < DialogaPlugin::ReportJob
3 3
4 def perform 4 def perform
5 profile = Profile.find(profile_id) 5 profile = Profile.find(profile_id)
6 - report_folder = create_report_path(profile) 6 + report_folder = DialogaPlugin::ReportJob.create_report_path(profile, report_path)
7 create_event_report(profile, report_folder) 7 create_event_report(profile, report_folder)
8 end 8 end
9 9
lib/dialoga_plugin/ranking_job.rb
@@ -4,7 +4,7 @@ class DialogaPlugin::RankingJob < DialogaPlugin::ReportJob @@ -4,7 +4,7 @@ class DialogaPlugin::RankingJob < DialogaPlugin::ReportJob
4 4
5 def perform 5 def perform
6 profile = Profile.find(profile_id) 6 profile = Profile.find(profile_id)
7 - report_folder = create_report_path(profile) 7 + report_folder = DialogaPlugin::ReportJob.create_report_path(profile, report_path)
8 create_ranking_report(profile, report_folder) 8 create_ranking_report(profile, report_folder)
9 end 9 end
10 10
lib/dialoga_plugin/report_job.rb
@@ -3,7 +3,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path) @@ -3,7 +3,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path)
3 3
4 include ActionDispatch::TestProcess 4 include ActionDispatch::TestProcess
5 5
6 - def create_report_path(profile) 6 + def self.create_report_path(profile, report_path)
7 root_report_folder = profile.folders.where(:slug => 'relatorios').first 7 root_report_folder = profile.folders.where(:slug => 'relatorios').first
8 root_report_folder ||= Folder.create!(:profile => profile, :name => 'Relatorios') 8 root_report_folder ||= Folder.create!(:profile => profile, :name => 'Relatorios')
9 FileUtils.mkdir_p "/tmp/#{report_path}" 9 FileUtils.mkdir_p "/tmp/#{report_path}"
@@ -23,7 +23,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path) @@ -23,7 +23,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path)
23 23
24 def perform 24 def perform
25 profile = Profile.find(profile_id) 25 profile = Profile.find(profile_id)
26 - report_folder = create_report_path(profile) 26 + report_folder = DialogaPlugin::ReportJob.create_report_path(profile, report_path)
27 create_proposals_report(profile, report_folder) 27 create_proposals_report(profile, report_folder)
28 end 28 end
29 29