From 230094ef8f456a3ac7d246f3f980126f8fa79a3c Mon Sep 17 00:00:00 2001 From: Dhruv Kapadia Date: Mon, 8 Feb 2010 16:59:13 -0500 Subject: [PATCH] Minor changes to rake task --- app/models/cron_mailer.rb | 2 +- lib/tasks/test_api.rake | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/models/cron_mailer.rb b/app/models/cron_mailer.rb index b4ab048..2b851c9 100644 --- a/app/models/cron_mailer.rb +++ b/app/models/cron_mailer.rb @@ -2,7 +2,7 @@ class CronMailer < ActionMailer::Base def error_message(subject, message, sent_at= Time.now) @from = 'cronjob@allourideas.org' - @recipients = "dhruv@dkapadia.com" + @recipients = "dhruv@allourideas.org" @subject ="[All Our Ideas] " + subject @sent_on = sent_at @body[:message] = message diff --git a/lib/tasks/test_api.rake b/lib/tasks/test_api.rake index a8cdf7a..8cbc2b3 100644 --- a/lib/tasks/test_api.rake +++ b/lib/tasks/test_api.rake @@ -1,5 +1,7 @@ namespace :test_api do + task :all => [:question_vote_consistency] + desc "Description here" task(:question_vote_consistency => :environment) do questions = Question.find(:all) @@ -9,6 +11,7 @@ namespace :test_api do total_wins =0 total_votes =0 + error_bool = false question.choices.each do |choice| if choice.wins @@ -23,17 +26,31 @@ namespace :test_api do if (2*total_wins != total_votes) - error_msg += "Error:" + error_msg += "Error 1:" + error_bool= true end if(total_votes % 2 != 0) - error_msg += "ERROR" + error_msg += "Error 2:" + error_bool= true + end + + if(total_votes != question.votes_count) + error_msg += "Error 3:" + error_bool = true end - error_msg += "Question #{question.id}: 2*wins = #{2*total_wins}, total votes = #{total_votes}\n" + if error_bool + error_msg += "Question #{question.id}: 2*wins = #{2*total_wins}, total votes = #{total_votes}, vote_count = #{question.votes_count}\n" + end + + error_bool = false + end - CronMailer.deliver_error_message("This is a test", "") + if error_msg + CronMailer.deliver_error_message("Data in api check error!", error_msg) + end end end -- libgit2 0.21.2