Class: Holistics::Imports
Class Method Summary
collapse
Instance Method Summary
collapse
banner, subcommand_prefix
Constructor Details
#initialize(*args) ⇒ Imports
Returns a new instance of Imports.
Class Method Details
.help(*args) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/holistics/imports.rb', line 7
def self.help(*args)
super
puts <<-INSTRUCTION
Examples:
holistics imports list # List all import jobs
INSTRUCTION
end
|
Instance Method Details
#execute(id) ⇒ Object
61
62
63
64
65
66
|
# File 'lib/holistics/imports.rb', line 61
def execute(id)
puts "`imports execute #{id}` called with options: #{options}" if Holistics.debug?
result = @this.execute(id)
puts 'Job ID: ' + result['job_id'].to_s.yellow + " Submit: " + Holistics::Utils.colorize(result['status'])
invoke 'holistics:jobs:logs', [result['job_id']], { follow: true }
end
|
#list ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/holistics/imports.rb', line 17
def list
puts "`imports list` called with options: #{options}" if Holistics.debug?
tp(
@this.all.map do |item|
source = case item['source_type']
when 'dbtable'
source_config = item['source_config'][item['source_type']]
"(#{source_config['ds_id']}) #{source_config['fqname']}"
else
item['source_label']
end
destination = "(#{item['dest_ds_id']}) " + [item['dest_schema_name'], item['dest_table_name']].map(&:to_s).join('.')
last_run_status = if item['last_run_job']
case item['last_run_job']['status']
when 'success' then item['last_run_job']['status'].green
when 'failed' then item['last_run_job']['status'].red
else
item['last_run_job']['status']
end
else
'unknown'.yellow
end
{
id: item['id'],
title: item['title'],
owner: item['owner_name'],
source: source,
destination: destination,
created_at: item['created_at'] ? DateTime.parse(item['created_at']).to_formatted_s(:short) : nil,
last_run: item['last_run'] ? DateTime.parse(item['last_run']).to_formatted_s(:short) : nil,
last_run_status: last_run_status
}
end
)
end
|