Commit 1fbad28c2fbb0b721105af0980cc516fd666f574

Authored by Leandro Santos
1 parent 5a1883a6

moving scripts to dialoga plugin context

plugins/dialoga
1   -Subproject commit f15d572167ea9402a41a351288217319307ca129
  1 +Subproject commit 14cab1934b678869e16e9e0943d0e7a93baaba21
... ...
script/sent_event_report
... ... @@ -1,27 +0,0 @@
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(File.join(Rails.root,'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   -
script/sent_proposal_report
... ... @@ -1,54 +0,0 @@
1   -#!/usr/bin/env ruby
2   -require File.dirname(__FILE__) + '/../config/environment'
3   -require 'net/smtp'
4   -
5   -
6   -emails = ['leandronunes@gmail.com', 'leandro.santos@serpro.gov.br'] + ARGV
7   -emails.uniq!
8   -
9   -puts 'Iniciando script'
10   -
11   -file = File.open(File.join(Rails.root,'data.csv'), 'w+')
12   -
13   -tasks = ProposalsDiscussionPlugin::ProposalTask.all
14   -count = 0
15   -header = "'Origem';'Status';'Criada em';'Moderado por';'Data de Moderado';'Validado por';'Data de Validado';'Autor';'Proposta'\n"
16   -file.write(header)
17   -STATUS_TRANSLATION = {
18   - 1 => 'Pendente de Moderacao',
19   - 2 => 'Rejeitada',
20   - 3 => 'Aprovada',
21   - 5 => 'Pre Aprovada',
22   - 6 => 'Pre Rejeitada',
23   -}
24   -tasks.map do |task|
25   - count += 1
26   - puts "%s de %s: adicionando task: %s" % [count, tasks.count, task.id ]
27   - info = []
28   - info.push(task.proposal_source)
29   - info.push(STATUS_TRANSLATION[task.status])
30   - info.push(task.created_at.strftime("%d/%m/%y %H:%M"))
31   - info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.evaluated_by.name : '')
32   - info.push(task.proposal_evaluation.present? ? task.proposal_evaluation.created_at.strftime("%d/%m/%y %H:%M") : '')
33   - info.push(task.closed_by.present? ? task.closed_by.name : '')
34   - info.push(task.closed_by.present? ? task.end_date.strftime("%d/%m/%y %H:%M") : '')
35   - info.push(task.requestor.present? ? task.requestor.name : '')
36   - info.push(task.abstract.present? ? task.abstract.gsub(/\s+/, ' ').strip : '')
37   - file.write(info.map{|i| "'" + i.to_s + "'"}.join(";"))
38   - file.write("\n")
39   -end
40   -
41   -file.close
42   -
43   -ActionMailer::Base.logger = Logger.new(STDOUT)
44   -class Sender < ActionMailer::Base
45   - def send_report(to, from)
46   - attachments["eventos.csv"] = File.read("#{Rails.root}/event.csv")
47   - attachments["propostas.csv"] = File.read("#{Rails.root}/data.csv")
48   - mail to: to, from: from,
49   - subject: "Relatorio do Dialoga", body: "Segue em anexo os relatorios do Dialoga"
50   - end
51   -
52   -end
53   -
54   -Sender.send_report(emails, 'dialoga@dialoga.gov.br').deliver