Commit 7fb05fecf22a0692a94c8fdd4c45545d21cb7999
Exists in
master
Merge branch 'master' of https://gitlab.com/participa/dialoga-plugin
Showing
3 changed files
with
13 additions
and
15 deletions
Show diff stats
lib/dialoga_plugin/event_job.rb
... | ... | @@ -11,21 +11,19 @@ class DialogaPlugin::EventJob < DialogaPlugin::ReportJob |
11 | 11 | events = Event.where(:profile_id => profile.id) |
12 | 12 | events.map do |event| |
13 | 13 | filepath = "/tmp/#{report_path}/evento-#{event.slug}.csv" |
14 | - file = File.open(File.join(filepath), 'w+') | |
15 | - file.write(event.name+ "\n") | |
16 | - header = "'Nome';'Email'\n" | |
17 | - file.write(header) | |
18 | 14 | count = 0 |
19 | - event.person_followers.map do |person| | |
20 | - count += 1 | |
21 | - puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] | |
22 | - info = [] | |
23 | - info.push(person.name) | |
24 | - info.push(person.email) | |
25 | - file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) | |
26 | - file.write("\n") | |
15 | + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| | |
16 | + csv << [event.name] | |
17 | + csv << ['Nome', 'Email'] | |
18 | + event.person_followers.map do |person| | |
19 | + count += 1 | |
20 | + puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] | |
21 | + info = [] | |
22 | + info.push(person.name) | |
23 | + info.push(person.email) | |
24 | + csv << info | |
25 | + end | |
27 | 26 | end |
28 | - file.close | |
29 | 27 | end |
30 | 28 | upload_file(compress_files('eventos', 'evento-*'), profile, report_folder) |
31 | 29 | end | ... | ... |
lib/dialoga_plugin/ranking_job.rb
... | ... | @@ -17,7 +17,7 @@ class DialogaPlugin::RankingJob < DialogaPlugin::ReportJob |
17 | 17 | next if ranking.empty? |
18 | 18 | |
19 | 19 | filepath = "/tmp/#{report_path}/ranking-#{discussion.slug}_#{article.slug}.csv" |
20 | - CSV.open(filepath, 'w' ) do |csv| | |
20 | + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true}) do |csv| | |
21 | 21 | csv << ['Posição', 'Id', 'Proposta', 'Positivo', 'Negativo', 'Exibições', 'Valor'] |
22 | 22 | ranking.each_with_index {|r, i| csv << [i+1, r.values].flatten} |
23 | 23 | end | ... | ... |
lib/dialoga_plugin/report_job.rb
... | ... | @@ -30,7 +30,7 @@ class DialogaPlugin::ReportJob < Struct.new(:profile_id, :report_path) |
30 | 30 | def create_proposals_report(profile, report_folder) |
31 | 31 | filepath = "/tmp/#{report_path}/propostas.csv" |
32 | 32 | |
33 | - CSV.open(filepath, 'w', {:col_sep => ';'} ) do |csv| | |
33 | + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| | |
34 | 34 | tasks = ProposalsDiscussionPlugin::ProposalTask.all |
35 | 35 | count = 0 |
36 | 36 | csv << ['Origem', 'Status', 'Criada em', 'Moderado por', 'Data de Moderado', 'Validado por', 'Data de Validado', 'Autor', 'Proposta', 'Categorias', 'Tema'] | ... | ... |