diff --git a/lib/dialoga_plugin/event_job.rb b/lib/dialoga_plugin/event_job.rb index 375d3e9..6a6ca62 100644 --- a/lib/dialoga_plugin/event_job.rb +++ b/lib/dialoga_plugin/event_job.rb @@ -11,21 +11,19 @@ class DialogaPlugin::EventJob < DialogaPlugin::ReportJob events = Event.where(:profile_id => profile.id) events.map do |event| filepath = "/tmp/#{report_path}/evento-#{event.slug}.csv" - file = File.open(File.join(filepath), 'w+') - file.write(event.name+ "\n") - header = "'Nome';'Email'\n" - file.write(header) count = 0 - event.person_followers.map do |person| - count += 1 - puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] - info = [] - info.push(person.name) - info.push(person.email) - file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) - file.write("\n") + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| + csv << [event.name] + csv << ['Nome', 'Email'] + event.person_followers.map do |person| + count += 1 + puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] + info = [] + info.push(person.name) + info.push(person.email) + csv << info + end end - file.close end upload_file(compress_files('eventos', 'evento-*'), profile, report_folder) end diff --git a/lib/dialoga_plugin/ranking_job.rb b/lib/dialoga_plugin/ranking_job.rb index 8a6ebcb..4c1d685 100644 --- a/lib/dialoga_plugin/ranking_job.rb +++ b/lib/dialoga_plugin/ranking_job.rb @@ -17,7 +17,7 @@ class DialogaPlugin::RankingJob < DialogaPlugin::ReportJob next if ranking.empty? filepath = "/tmp/#{report_path}/ranking-#{discussion.slug}_#{article.slug}.csv" - CSV.open(filepath, 'w' ) do |csv| + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true}) do |csv| csv << ['Posição', 'Id', 'Proposta', 'Positivo', 'Negativo', 'Exibições', 'Valor'] ranking.each_with_index {|r, i| csv << [i+1, r.values].flatten} end diff --git a/lib/dialoga_plugin/report_job.rb b/lib/dialoga_plugin/report_job.rb index aad0c16..c5a1d3c 100644 --- a/lib/dialoga_plugin/report_job.rb +++ b/lib/dialoga_plugin/report_job.rb @@ -30,7 +30,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path) def create_proposals_report(profile, report_folder) filepath = "/tmp/#{report_path}/propostas.csv" - CSV.open(filepath, 'w', {:col_sep => ';'} ) do |csv| + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| tasks = ProposalsDiscussionPlugin::ProposalTask.all count = 0 csv << ['Tema', 'Origem', 'Status', 'Criada em', 'Moderado por', 'Data de Moderado', 'Validado por', 'Data de Validado', 'Autor', 'Proposta', 'Categorias'] -- libgit2 0.21.2