Skip to content
This repository
Browse code

don't rely on a named_scope with update_all

  • Loading branch information...
commit 944c55851811f1d8dcfed59d2d85ecf8112c008d 1 parent 947ed9b
Jeremy Ashkenas authored

Showing 1 changed file with 2 additions and 1 deletion. Show diff stats Hide diff stats

  1. 3  lib/cloud_crowd/models/work_unit.rb
3  lib/cloud_crowd/models/work_unit.rb
@@ -81,7 +81,8 @@ def self.distribute_to_nodes
81 81
     # were none available.
82 82
     def self.reserve_available(options={})
83 83
       reservation = ActiveSupport::SecureRandom.random_number(MAX_RESERVATION)
84  
-      any = WorkUnit.available.update_all("reservation = #{reservation}", options[:conditions], options) > 0
  84
+      conditions = "reservation is null and worker_pid is null and status is #{INCOMPLETE} and #{options[:conditions]}"
  85
+      any = WorkUnit.update_all("reservation = #{reservation}", conditions, options) > 0
85 86
       any && reservation
86 87
     end
87 88
 

0 notes on commit 944c558

Please sign in to comment.
Something went wrong with that request. Please try again.