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
return if ENV['BULK_PROCESS']
recipient.update_attributes(
attempts_count: recipient.attempts.count,
responses_count: recipient.attempts.with_answer.count
)
recipient.update_counts
end
end

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

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

Loading…
Cancel
Save