Commit 767ed869571237302dd964f073ebdbc65f8dd220
1 parent
e79d6a28
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding scripts
Showing
3 changed files
with
83 additions
and
1 deletions
Show diff stats
plugins/proposals_discussion
| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require File.dirname(__FILE__) + '/../config/environment' | |
| 3 | +require 'net/smtp' | |
| 4 | + | |
| 5 | +puts 'Iniciando script' | |
| 6 | + | |
| 7 | +file = File.open('event.csv', 'w+') | |
| 8 | + | |
| 9 | +events = Event.all | |
| 10 | +events.map do |event| | |
| 11 | + file.write(event.name+ "\n") | |
| 12 | + header = "'Nome';'Email'\n" | |
| 13 | + file.write(header) | |
| 14 | + count = 0 | |
| 15 | + event.person_followers.map do |person| | |
| 16 | + count += 1 | |
| 17 | + puts "%s de %s: adicionando evento: %s" % [count, event.person_followers.count, event.id ] | |
| 18 | + info = [] | |
| 19 | + info.push(person.name) | |
| 20 | + info.push(person.email) | |
| 21 | + file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) | |
| 22 | + file.write("\n") | |
| 23 | + end | |
| 24 | +end | |
| 25 | + | |
| 26 | +file.close | |
| 27 | + | ... | ... |
| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | +#!/usr/bin/env ruby | |
| 2 | +require File.dirname(__FILE__) + '/../config/environment' | |
| 3 | +require 'net/smtp' | |
| 4 | + | |
| 5 | +mails = ['leandronunes@gmail.com', 'leandro.santos@serpro.gov.br'] | |
| 6 | + | |
| 7 | +puts 'Iniciando script' | |
| 8 | + | |
| 9 | +file = File.open('data.csv', 'w+') | |
| 10 | + | |
| 11 | +#articles = ProposalsDiscussionPlugin::Proposal.all | |
| 12 | +tasks = ProposalsDiscussionPlugin::ProposalTask.all | |
| 13 | +count = 0 | |
| 14 | +header = "'Origem';'Status';'Criada em';'Moderado por';'Data de Moderado';'Validado por';'Data de Validado';'Autor';'Proposta'\n" | |
| 15 | +file.write(header) | |
| 16 | +STATUS_TRANSLATION = { | |
| 17 | + 1 => 'Pendente de Moderacao', | |
| 18 | + 2 => 'Rejeitada', | |
| 19 | + 3 => 'Aprovada', | |
| 20 | + 5 => 'Pre Aprovada', | |
| 21 | + 6 => 'Pre Rejeitada', | |
| 22 | +} | |
| 23 | +tasks.map do |task| | |
| 24 | + count += 1 | |
| 25 | + puts "%s de %s: adicionando task: %s" % [count, tasks.count, task.id ] | |
| 26 | + info = [] | |
| 27 | + info.push(task.proposal_source) | |
| 28 | + info.push(STATUS_TRANSLATION[task.status]) | |
| 29 | + info.push(task.created_at.strftime("%d/%m/%y %H:%M")) | |
| 30 | + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.evaluated_by.name : '') | |
| 31 | + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.created_at.strftime("%d/%m/%y %H:%M") : '') | |
| 32 | + info.push(task.closed_by.present? ? task.closed_by.name : '') | |
| 33 | + info.push(task.closed_by.present? ? task.end_date.strftime("%d/%m/%y %H:%M") : '') | |
| 34 | + info.push(task.requestor.present? ? task.requestor.name : '') | |
| 35 | + info.push(task.abstract.present? ? task.abstract.gsub(/\s+/, ' ').strip : '') | |
| 36 | + file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) | |
| 37 | + file.write("\n") | |
| 38 | +end | |
| 39 | + | |
| 40 | +file.close | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | +message = <<MESSAGE_END | |
| 45 | +From: Relatorio Dialoga <relatorio@dialoga.gov.br> | |
| 46 | +To: Leandro <leandronunes@gmail.com> | |
| 47 | +Subject: Relatorio do Dialoga | |
| 48 | + | |
| 49 | +Segue em anexo o relatorio do Dialoga. | |
| 50 | +MESSAGE_END | |
| 51 | + | |
| 52 | +Net::SMTP.start('localhost') do |smtp| | |
| 53 | + smtp.send_message message, 'leandronunes@gmail.com', | |
| 54 | + 'leandro.santos@serpro.gov.br' | |
| 55 | +end | ... | ... |