Class: EtnaApp::Magma::Models::LoadFromRedcap
- Inherits:
-
Etna::Command
- Object
- Etna::Command
- EtnaApp::Magma::Models::LoadFromRedcap
- Includes:
- StrongConfirmation, WithEtnaClients, WithLogger
- Defined in:
- lib/commands.rb
Instance Attribute Summary
Attributes inherited from Etna::Command
Instance Method Summary collapse
- #clean_sne_message(chunk) ⇒ Object
- #execute(project_name, redcap_tokens, models: "all", mode: nil, commit: false) ⇒ Object
Methods included from StrongConfirmation
Methods included from WithLogger
Methods included from WithEtnaClients
#environment, #exit, exit, #janus_client, #magma_client, #metis_client, #polyphemus_client, #token
Methods inherited from Etna::Command
#completions, #fill_in_missing_params, #find_command, #initialize, parent_scope, #setup
Methods included from Etna::CommandOrExecutor
#command_name, #completions_for, #desc, #flag_argspec, #flag_as_parameter, included, #parse_flags, #program_name, #usage
Constructor Details
This class inherits a constructor from Etna::Command
Instance Method Details
#clean_sne_message(chunk) ⇒ Object
577 578 579 580 581 582 583 584 585 |
# File 'lib/commands.rb', line 577 def (chunk) chunk.split("\n").reject do |c| c.start_with?("retry:") || c.start_with?("event:") end.map do |c| c.gsub("data:", "").strip end.reject do |c| c.empty? end end |
#execute(project_name, redcap_tokens, models: "all", mode: nil, commit: false) ⇒ Object
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 |
# File 'lib/commands.rb', line 559 def execute(project_name, redcap_tokens, models: "all", mode: nil, commit: false) raise "Must provide at least one REDCap token (comma-separated)." unless redcap_tokens.split(',').length > 0 puts "NOTE: This is a **preview** of what the data loading will look like. Use the --commit flag to load records into Magma." unless commit polyphemus_client.job(Etna::Clients::Polyphemus::RedcapJobRequest.new( model_names: "all" == models ? "all" : models.split(','), mode: mode, redcap_tokens: redcap_tokens.split(','), project_name: project_name, commit: commit )) do |response| response.read_body do |chunk| puts (chunk) end end end |