Commit d155fa25b7dc8c13336289d8427655b8c4c174e2
1 parent
230094ef
Exists in
master
and in
1 other branch
Added helpful output on cron job success
Showing
6 changed files
with
24 additions
and
24 deletions
Show diff stats
app/models/cron_mailer.rb
1 | 1 | class CronMailer < ActionMailer::Base |
2 | 2 | |
3 | - def error_message(subject, message, sent_at= Time.now) | |
3 | + def info_message(recipients, subject, message, sent_at= Time.now) | |
4 | + @recipients = recipients | |
4 | 5 | @from = 'cronjob@allourideas.org' |
5 | - @recipients = "dhruv@allourideas.org" | |
6 | 6 | @subject ="[All Our Ideas] " + subject |
7 | 7 | @sent_on = sent_at |
8 | 8 | @body[:message] = message | ... | ... |
app/views/cron_mailer/error_message.erb
app/views/cron_mailer/error_message.haml
config/initializers/mail.rb
lib/tasks/test_api.rake
... | ... | @@ -24,32 +24,31 @@ namespace :test_api do |
24 | 24 | end |
25 | 25 | end |
26 | 26 | |
27 | - | |
28 | 27 | if (2*total_wins != total_votes) |
29 | - error_msg += "Error 1:" | |
28 | + error_msg += "Error 1: 2 x Total Wins != Total votes" | |
30 | 29 | error_bool= true |
31 | 30 | end |
32 | 31 | |
33 | 32 | if(total_votes % 2 != 0) |
34 | - error_msg += "Error 2:" | |
33 | + error_msg += "Error 2: Total votes is not Even!" | |
35 | 34 | error_bool= true |
36 | 35 | end |
37 | 36 | |
38 | - if(total_votes != question.votes_count) | |
39 | - error_msg += "Error 3:" | |
37 | + if(total_votes != 2* question.votes_count) | |
38 | + error_msg += "Error 3: Total votes != 2 x # vote objects" | |
40 | 39 | error_bool = true |
41 | 40 | end |
42 | 41 | |
43 | 42 | if error_bool |
44 | 43 | error_msg += "Question #{question.id}: 2*wins = #{2*total_wins}, total votes = #{total_votes}, vote_count = #{question.votes_count}\n" |
45 | 44 | end |
46 | - | |
47 | 45 | error_bool = false |
48 | - | |
49 | 46 | end |
50 | 47 | |
51 | - if error_msg | |
52 | - CronMailer.deliver_error_message("Data in api check error!", error_msg) | |
48 | + if error_msg.blank? | |
49 | + CronMailer.deliver_info_message(CRON_EMAIL, "Test of API Vote Consistency passed", "Examined #{questions.count} questions and found no irregulaties") | |
50 | + else | |
51 | + CronMailer.deliver_info_message("#{CRON_EMAIL},#{ERRORS_EMAIL}", "Error! Failure of API Vote Consistency " , error_msg) | |
53 | 52 | end |
54 | 53 | |
55 | 54 | end | ... | ... |