I call this method in the console:
pry(main)> Resque.enqueue(GameMetrics, 142)
=> true
Here is the error on the Resque front-end in Game Metrics Queue's failed jobs tab after performing the above:
Here is my perform method(within the job folder):
class GameMetrics
@queue = :game_metrics
def self.perform(game_id)
game = Game.find(game_id)
if game.data_recorded? == false && game.number == 1 && game.user.is_admin? == false
game.answered_game_questions.includes(:question).each do |game_question|
company_question = CompanyQuestion.find_or_create_by(company: game.company, question: game_question.question)
company_question.increment(:freq_100_credit_gained) if game_question.change_in_earnings == 100
company_question.increment(:freq_over_49_lost_of_total_poss_loss) if game_question.percentage_points_lost > 49
company_question.increment(:freq_over_66_lost_of_total_poss_loss) if game_question.percentage_points_lost > 66
company_question.increment(:freq_answered)
company_question.save
end
end
game.update(data_recorded?: true)
end
end
There is indeed a game with ID 142 so what could be the issue here? Thank you!! I'm using rails 4.2 and resque 1.22.0
After many hours of head banging I figured out that I just needed to restart my
rake QUEUE=* environment resque:work
task to load up the new environment/working code.
I had thought of restarting the local redis server but forgot about the rake task.
TL;DR restart all your shit when you change code and don't understand why shit doesn't work
Hope this helps someone!