diff --git a/lib/juventude_plugin/followers_job.rb b/lib/juventude_plugin/followers_job.rb index a9167a6..7ff8c8e 100644 --- a/lib/juventude_plugin/followers_job.rb +++ b/lib/juventude_plugin/followers_job.rb @@ -22,7 +22,7 @@ class JuventudePlugin::FollowersJob < JuventudePlugin::ReportJob => ArticleFollower(id: integer, person_id: integer, article_id: integer, since: datetime, created_at: datetime, updated_at: datetime) info.push(article_follower.article_id) - info.push(article_follower.person_id) + info.push(article_follower.person.identifier) info.push(article_follower.created_at.strftime("%d/%m/%y %H:%M")) csv << info end diff --git a/lib/juventude_plugin/votes_job.rb b/lib/juventude_plugin/votes_job.rb new file mode 100644 index 0000000..f427cd9 --- /dev/null +++ b/lib/juventude_plugin/votes_job.rb @@ -0,0 +1,34 @@ +# encoding: UTF-8 +class JuventudePlugin::VotesJob < JuventudePlugin::ReportJob + + def perform + profile = Profile.find(profile_id) + report_folder = JuventudePlugin::ReportJob.create_report_path(profile, report_path) + create_votes_report(profile, report_folder) + end + + def create_votes_report(profile, report_folder) + proposals = ProposalsDiscussionPlugin::Proposal.all + filepath = "/tmp/#{report_path}/votes.csv" + CSV.open(filepath, 'w', {:col_sep => ';', :force_quotes => true} ) do |csv| + csv << ['Id Artigo Votado','Id Pessoa que votou','Data'] + proposals.map do |proposal| + count = 0 + amount_proposal_votes = proposal.votes.count + proposal.votes.map do |vote| + count += 1 + puts "%s de %s: adicionando voto da proposta: %s" % [count, amount_proposal_votes, proposal.id ] + info = [] + => ArticleFollower(id: integer, person_id: integer, article_id: integer, since: datetime, created_at: datetime, updated_at: datetime) + + info.push(vote.voteable_id) + info.push(vote.voter.identifier) + info.push(vote.created_at.strftime("%d/%m/%y %H:%M")) + csv << info + end + end + end + upload_file(compress_files('votes', 'votes.csv'), profile, report_folder) + end + +end -- libgit2 0.21.2