From 767ed869571237302dd964f073ebdbc65f8dd220 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Tue, 4 Aug 2015 23:18:42 -0300 Subject: [PATCH] adding scripts --- plugins/proposals_discussion | 2 +- script/sent_event_report | 27 +++++++++++++++++++++++++++ script/sent_proposal_report | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100755 script/sent_event_report create mode 100755 script/sent_proposal_report diff --git a/plugins/proposals_discussion b/plugins/proposals_discussion index 7e2853f..bc3e832 160000 --- a/plugins/proposals_discussion +++ b/plugins/proposals_discussion @@ -1 +1 @@ -Subproject commit 7e2853fcea820505bf1682c509fd42af7b907775 +Subproject commit bc3e832ee4f96edbefa5d377a332e4c67cdffa35 diff --git a/script/sent_event_report b/script/sent_event_report new file mode 100755 index 0000000..968dbb8 --- /dev/null +++ b/script/sent_event_report @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +require File.dirname(__FILE__) + '/../config/environment' +require 'net/smtp' + +puts 'Iniciando script' + +file = File.open('event.csv', 'w+') + +events = Event.all +events.map do |event| + 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") + end +end + +file.close + diff --git a/script/sent_proposal_report b/script/sent_proposal_report new file mode 100755 index 0000000..ac2ac61 --- /dev/null +++ b/script/sent_proposal_report @@ -0,0 +1,55 @@ +#!/usr/bin/env ruby +require File.dirname(__FILE__) + '/../config/environment' +require 'net/smtp' + +mails = ['leandronunes@gmail.com', 'leandro.santos@serpro.gov.br'] + +puts 'Iniciando script' + +file = File.open('data.csv', 'w+') + +#articles = ProposalsDiscussionPlugin::Proposal.all +tasks = ProposalsDiscussionPlugin::ProposalTask.all +count = 0 +header = "'Origem';'Status';'Criada em';'Moderado por';'Data de Moderado';'Validado por';'Data de Validado';'Autor';'Proposta'\n" +file.write(header) +STATUS_TRANSLATION = { + 1 => 'Pendente de Moderacao', + 2 => 'Rejeitada', + 3 => 'Aprovada', + 5 => 'Pre Aprovada', + 6 => 'Pre Rejeitada', +} +tasks.map do |task| + count += 1 + puts "%s de %s: adicionando task: %s" % [count, tasks.count, task.id ] + info = [] + info.push(task.proposal_source) + info.push(STATUS_TRANSLATION[task.status]) + info.push(task.created_at.strftime("%d/%m/%y %H:%M")) + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.evaluated_by.name : '') + info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.created_at.strftime("%d/%m/%y %H:%M") : '') + info.push(task.closed_by.present? ? task.closed_by.name : '') + info.push(task.closed_by.present? ? task.end_date.strftime("%d/%m/%y %H:%M") : '') + info.push(task.requestor.present? ? task.requestor.name : '') + info.push(task.abstract.present? ? task.abstract.gsub(/\s+/, ' ').strip : '') + file.write(info.map{|i| "'" + i.to_s + "'"}.join(";")) + file.write("\n") +end + +file.close + + + +message = < +To: Leandro +Subject: Relatorio do Dialoga + +Segue em anexo o relatorio do Dialoga. +MESSAGE_END + +Net::SMTP.start('localhost') do |smtp| + smtp.send_message message, 'leandronunes@gmail.com', + 'leandro.santos@serpro.gov.br' +end -- libgit2 0.21.2