better bulk uploading

pull/1/head
Jared Cosulich 8 years ago
parent 62a9f9c194
commit ee44c1227c

@ -79,10 +79,7 @@ class Attempt < ApplicationRecord
def update_counts def update_counts
return if ENV['BULK_PROCESS'] return if ENV['BULK_PROCESS']
recipient.update_attributes( recipient.update_counts
attempts_count: recipient.attempts.count,
responses_count: recipient.attempts.with_answer.count
)
end end
end end

@ -29,6 +29,13 @@ class Recipient < ApplicationRecord
end end
end end
def update_counts
update_attributes(
attempts_count: attempts.count,
responses_count: attempts.with_answer.count
)
end
private private
def sync_lists def sync_lists

@ -254,5 +254,6 @@ namespace :data do
ENV.delete('BULK_PROCESS') ENV.delete('BULK_PROCESS')
SchoolCategory.all.each { |sc| sc.sync_aggregated_responses } SchoolCategory.all.each { |sc| sc.sync_aggregated_responses }
Recipient.all.each { |r| r.update_counts }
end end
end end

Loading…
Cancel
Save