@ -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
@ -29,6 +29,13 @@ class Recipient < ApplicationRecord
update_attributes(
attempts_count: attempts.count,
responses_count: attempts.with_answer.count
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 }