Skip to content

Instantly share code, notes, and snippets.

@justinrolston
Created September 17, 2012 15:51
Show Gist options
  • Save justinrolston/3738137 to your computer and use it in GitHub Desktop.
Save justinrolston/3738137 to your computer and use it in GitHub Desktop.
requeue my code
def requeue_failures(date)
failing_features = []
FunctionalTestResult.where(:when_ran => date, :outcome => ['fail', 'fail-new']).select(:feature).uniq.each do |result|
newest = FunctionalTestResult.where(:when_ran => date, :feature => result.feature).order('id DESC').first
unless newest.outcome == 'resolved' || newest.outcome == 'success'
features = Feature.where(:is_current => true, :name => "Feature: #{result.feature}")
.select(:full_file_name)
.uniq
features.collect{|f| f.full_file_name.split('GainWeb\\').last}.each do |feature|
failing_features << feature unless failing_features.include?(feature)
end
end
end
build_assignments(failing_features, date)
end
def queue_by_tag(tag, key)
features = Feature.where('tags like ?', "%#{tag}%")
.select(:full_file_name)
.uniq
build_assignments(features.map{|f| f.full_file_name.split('\\').last}, key)
end
def requeue_after_1_hour(run_date)
puts 'Prior to Requeing'
status (run_date)
puts 'Requeing...'
@collection.update({'status' => /Running/, 'run_date' => run_date, 'picked_on' => {'&lt' => Chronic.parse('1 hour ago')}},
{'status' => 'ready', 'fail_count' => 0},
:multi => true)
puts 'After Requeueing'
status(run_date)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment