Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix associate_answers_with_search_results task

  • Loading branch information...
commit e634c03a091ef36ed40bfd60768bfd4619a12cfe 1 parent 9c3442f
Ricardo Panaggio authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/tasks/answers_into_search_results.rake
View
10 lib/tasks/answers_into_search_results.rake
@@ -127,7 +127,7 @@ namespace :data do
raise 'You must have created a Group' unless Group.exists?
Answer.find_each(:batch_size => 100) do |answer|
- search_results = SearchResult.where(:question_id => answer.question_id, :user_id => answer.user_id)
+ search_results = SearchResult.where(:question_id => answer.question_id, :user_id => answer.user_id).all
search_result =
case count = search_results.count
@@ -135,13 +135,17 @@ namespace :data do
search_results.first
else
search_results.find do |sr|
- sr.url == answer_url(answer)
+ sr.url == Rails.application.routes.url_helpers.question_answer_url(answer.question, answer.id)
end
end
if search_results
answer.search_result = search_result
- answer.save
+ begin
+ answer.save!
+ rescue StandardError
+ STDERR.puts $!
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.