Class: EtnaApp::Administrate::Models::LoadFromRedcap
- Inherits:
-
Etna::Command
- Object
- Etna::Command
- EtnaApp::Administrate::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
374 375 376 377 378 379 380 381 382 |
# File 'lib/commands.rb', line 374 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
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/commands.rb', line 356 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 |