Commit 230094ef8f456a3ac7d246f3f980126f8fa79a3c
1 parent
310c2af6
Exists in
master
and in
1 other branch
Minor changes to rake task
Showing
2 changed files
with
22 additions
and
5 deletions
Show diff stats
app/models/cron_mailer.rb
@@ -2,7 +2,7 @@ class CronMailer < ActionMailer::Base | @@ -2,7 +2,7 @@ class CronMailer < ActionMailer::Base | ||
2 | 2 | ||
3 | def error_message(subject, message, sent_at= Time.now) | 3 | def error_message(subject, message, sent_at= Time.now) |
4 | @from = 'cronjob@allourideas.org' | 4 | @from = 'cronjob@allourideas.org' |
5 | - @recipients = "dhruv@dkapadia.com" | 5 | + @recipients = "dhruv@allourideas.org" |
6 | @subject ="[All Our Ideas] " + subject | 6 | @subject ="[All Our Ideas] " + subject |
7 | @sent_on = sent_at | 7 | @sent_on = sent_at |
8 | @body[:message] = message | 8 | @body[:message] = message |
lib/tasks/test_api.rake
1 | namespace :test_api do | 1 | namespace :test_api do |
2 | 2 | ||
3 | + task :all => [:question_vote_consistency] | ||
4 | + | ||
3 | desc "Description here" | 5 | desc "Description here" |
4 | task(:question_vote_consistency => :environment) do | 6 | task(:question_vote_consistency => :environment) do |
5 | questions = Question.find(:all) | 7 | questions = Question.find(:all) |
@@ -9,6 +11,7 @@ namespace :test_api do | @@ -9,6 +11,7 @@ namespace :test_api do | ||
9 | 11 | ||
10 | total_wins =0 | 12 | total_wins =0 |
11 | total_votes =0 | 13 | total_votes =0 |
14 | + error_bool = false | ||
12 | question.choices.each do |choice| | 15 | question.choices.each do |choice| |
13 | 16 | ||
14 | if choice.wins | 17 | if choice.wins |
@@ -23,17 +26,31 @@ namespace :test_api do | @@ -23,17 +26,31 @@ namespace :test_api do | ||
23 | 26 | ||
24 | 27 | ||
25 | if (2*total_wins != total_votes) | 28 | if (2*total_wins != total_votes) |
26 | - error_msg += "Error:" | 29 | + error_msg += "Error 1:" |
30 | + error_bool= true | ||
27 | end | 31 | end |
28 | 32 | ||
29 | if(total_votes % 2 != 0) | 33 | if(total_votes % 2 != 0) |
30 | - error_msg += "ERROR" | 34 | + error_msg += "Error 2:" |
35 | + error_bool= true | ||
36 | + end | ||
37 | + | ||
38 | + if(total_votes != question.votes_count) | ||
39 | + error_msg += "Error 3:" | ||
40 | + error_bool = true | ||
31 | end | 41 | end |
32 | 42 | ||
33 | - error_msg += "Question #{question.id}: 2*wins = #{2*total_wins}, total votes = #{total_votes}\n" | 43 | + if error_bool |
44 | + error_msg += "Question #{question.id}: 2*wins = #{2*total_wins}, total votes = #{total_votes}, vote_count = #{question.votes_count}\n" | ||
45 | + end | ||
46 | + | ||
47 | + error_bool = false | ||
48 | + | ||
34 | end | 49 | end |
35 | 50 | ||
36 | - CronMailer.deliver_error_message("This is a test", "") | 51 | + if error_msg |
52 | + CronMailer.deliver_error_message("Data in api check error!", error_msg) | ||
53 | + end | ||
37 | 54 | ||
38 | end | 55 | end |
39 | end | 56 | end |