Skip to content

Instantly share code, notes, and snippets.

@jcreed
Created June 25, 2024 10:55
Show Gist options
  • Save jcreed/8cba74f61f04a62e79ea0efcd6de38b9 to your computer and use it in GitHub Desktop.
Save jcreed/8cba74f61f04a62e79ea0efcd6de38b9 to your computer and use it in GitHub Desktop.
Manual Extract of Field Manager data
# sign on to wa-field-manager pod to pull json
# you will need usernamne and password for eco use
curl -H "Content-Type: application/json" -u username:password http://wa-field-manager-web-svc/api/v1/master/field_data.json > fm.json
# from you local transfer files to local then to wa-app pod
# copy to local from eco - cp {eco name}/{pod name}:/path to file
kubectl cp wa-only-fm/wa-field-manager-web-7949cbf9c-vgmhx:/opt/app/fm.json fm.json
# copy to eco wa-app pod - cp {eco name}/{pod name}:/path to file dropoff
kubectl cp fm.json nf-70170/wa-app-695db457bd-q9ftt:/opt/app/fm.json
# sign on to wa-app pod that now contains the json
# enter rails console - all commands below are for rails console
# run below initialize values
u = User.where(email: 'jreed@liaisonedu.com').last
sync = FieldManagerSync.create!(user_identity_id: u.user_identities.last.id).tap(&:in_progress!)
file = Rails.root.join('fm.json')
fm_json = File.read(file)
fields_config = JSON.parse(fm_json)
# create method for loading field sync in console
def load_fields(fields_config, sync)
FieldLoader.add_update_field_categories!(fields_config, sync.id)
FieldLoader.add_update_fields!(fields_config, sync.id)
FieldLoader.add_update_associations_fields!(fields_config, sync.id)
FieldLoader.remove_cases_from_fields!(fields_config, sync.id)
FieldLoader.remove_fields!(fields_config, sync.id)
FieldLoader.remove_field_categories!(fields_config, sync.id)
FieldLoader.load_field_operators!
sync.successful! if sync.no_errors?
rescue StandardError => e
sync.log_error(e)
puts "failed sync"
sync.failed! unless sync.success_with_errors?
end
# then call load_fields in console
load_fields(fields_config, sync)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment