Commit 1aa48652e63b9fc1a29002ede8df2a1906b2d7bc
1 parent
8c9ea49d
Exists in
master
adding more data in csv
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
lib/juventude_plugin/people_job.rb
@@ -15,21 +15,22 @@ class JuventudePlugin::PeopleJob < JuventudePlugin::ReportJob | @@ -15,21 +15,22 @@ class JuventudePlugin::PeopleJob < JuventudePlugin::ReportJob | ||
15 | people = Person.all | 15 | people = Person.all |
16 | filepath = "/tmp/#{report_path}/people.csv" | 16 | filepath = "/tmp/#{report_path}/people.csv" |
17 | CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| | 17 | CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| |
18 | - csv << ['Identificador', 'Nome', 'Email', 'Orientação Sexual', 'Identidade de Gênero', 'Transgenero', 'Raça', 'Estado', 'Cidade'] | 18 | + csv << ['Identificador','Criado em','Nome', 'Email', 'Orientação Sexual', 'Identidade de Gênero', 'Transgenero', 'Raça', 'Estado', 'Cidade'] |
19 | count = 0 | 19 | count = 0 |
20 | people.map do |person| | 20 | people.map do |person| |
21 | count += 1 | 21 | count += 1 |
22 | puts "%s de %s: adicionando pessoa: %s" % [count, people.count, person.id ] | 22 | puts "%s de %s: adicionando pessoa: %s" % [count, people.count, person.id ] |
23 | info = [] | 23 | info = [] |
24 | info.push(person.identifier) | 24 | info.push(person.identifier) |
25 | + info.push(person.created_at.strftime("%d/%m/%y %H:%M")) | ||
25 | info.push(person.name) | 26 | info.push(person.name) |
26 | info.push(person.email) | 27 | info.push(person.email) |
27 | info.push(ORIENTACAO_SEXUAL[person.orientacao_sexual.to_i]) | 28 | info.push(ORIENTACAO_SEXUAL[person.orientacao_sexual.to_i]) |
28 | info.push(GENERO[person.identidade_genero.to_i]) | 29 | info.push(GENERO[person.identidade_genero.to_i]) |
29 | info.push(person.transgenero) | 30 | info.push(person.transgenero) |
30 | info.push(ETNIA[person.etnia.to_i]) | 31 | info.push(ETNIA[person.etnia.to_i]) |
31 | - info.push(person.city ? person.city.name : '') | ||
32 | - info.push(person.state ? person.state.name : '') | 32 | + info.push(person.city) |
33 | + info.push(person.state) | ||
33 | csv << info | 34 | csv << info |
34 | end | 35 | end |
35 | end | 36 | end |
lib/juventude_plugin/report_job.rb
@@ -33,7 +33,7 @@ class JuventudePlugin::ReportJob < Struct.new(:profile_id, :report_path) | @@ -33,7 +33,7 @@ class JuventudePlugin::ReportJob < Struct.new(:profile_id, :report_path) | ||
33 | CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| | 33 | CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| |
34 | proposals = ProposalsDiscussionPlugin::Proposal.all | 34 | proposals = ProposalsDiscussionPlugin::Proposal.all |
35 | count = 0 | 35 | count = 0 |
36 | - csv << ['Identificador','Criada em', 'Autor', 'Titulo', 'Proposta', 'Comentarios', 'Seguidores', 'Votos'] | 36 | + csv << ['Identificador','Criada em', 'Autor', 'Eixo', 'Titulo', 'Proposta', 'Comentarios', 'Seguidores', 'Votos', 'Cidade'] |
37 | proposals.map do |proposal| | 37 | proposals.map do |proposal| |
38 | count += 1 | 38 | count += 1 |
39 | puts "%s de %s: adicionando proposta: %s" % [count, proposals.count, proposal.id ] | 39 | puts "%s de %s: adicionando proposta: %s" % [count, proposals.count, proposal.id ] |
@@ -41,11 +41,13 @@ class JuventudePlugin::ReportJob < Struct.new(:profile_id, :report_path) | @@ -41,11 +41,13 @@ class JuventudePlugin::ReportJob < Struct.new(:profile_id, :report_path) | ||
41 | info.push(proposal.id) | 41 | info.push(proposal.id) |
42 | info.push(proposal.created_at.strftime("%d/%m/%y %H:%M")) | 42 | info.push(proposal.created_at.strftime("%d/%m/%y %H:%M")) |
43 | info.push(proposal.author ? proposal.author.identifier : '') | 43 | info.push(proposal.author ? proposal.author.identifier : '') |
44 | + info.push(proposal.topic.name) | ||
44 | info.push(proposal.title) | 45 | info.push(proposal.title) |
45 | info.push(proposal.abstract.present? ? proposal.abstract.gsub(/\s+/, ' ').strip : '') | 46 | info.push(proposal.abstract.present? ? proposal.abstract.gsub(/\s+/, ' ').strip : '') |
46 | info.push(proposal.comments_count) | 47 | info.push(proposal.comments_count) |
47 | info.push(proposal.followers.count) | 48 | info.push(proposal.followers.count) |
48 | info.push(proposal.votes_for) | 49 | info.push(proposal.votes_for) |
50 | + info.push(proposal.cities.map{|c|c.path}.join(',')) | ||
49 | csv << info | 51 | csv << info |
50 | end | 52 | end |
51 | end | 53 | end |