Skip to content

Commit

Permalink
Update data migration for ZM
Browse files Browse the repository at this point in the history
  • Loading branch information
samnang committed Jan 8, 2025
1 parent a549c32 commit 4c91377
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/models/call_flow_logic/mama_info_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,22 @@ def persist_unconfirmed_date_of_birth
end

def persist_date_of_birth
contact = phone_call.contact
date_of_birth = metadata(phone_call, :unconfirmed_date_of_birth)
update_metadata!(phone_call, date_of_birth: date_of_birth)
update_metadata!(phone_call.contact, date_of_birth: date_of_birth)
phone_call.contact.metadata.delete("deregistered_at")
phone_call.contact.save!
update_metadata!(contact, date_of_birth: date_of_birth)
contact.metadata.delete("deregistered_at")
contact.date_of_birth = date_of_birth
contact.status = :active
contact.save!
end

def persist_deregistered
contact = phone_call.contact
update_metadata!(phone_call.contact, deregistered_at: Time.current)
phone_call.contact.metadata.delete("date_of_birth")
phone_call.contact.save!
contact.status = :disabled
contact.save!
end

def play(filename, response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ namespace :data_migrations do
ApplicationRecord.transaction do
contact.update_columns(
iso_country_code: ACCOUNT_COUNTRY_CODES.fetch(account.id),
language_code: contact.metadata["language_code"]
language_code: contact.metadata["language_code"],
date_of_birth: contact.metadata["date_of_birth"],
status: contact.metadata["deregistered_at"].present? ? :disabled : :active
)

# EWS Cambodia
Expand Down

0 comments on commit 4c91377

Please sign in to comment.