Class: Holistics::Transforms

Inherits:
SubcommandBase show all
Defined in:
lib/holistics/transforms.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SubcommandBase

banner, subcommand_prefix

Constructor Details

#initialize(*args) ⇒ Transforms


3
4
5
6
# File 'lib/holistics/transforms.rb', line 3

def initialize(*args)
  super
  @this = Model::JobDefinition.new(Holistics.client, 'data_transforms')
end

Class Method Details

.help(*args) ⇒ Object


7
8
9
10
11
12
13
14
# File 'lib/holistics/transforms.rb', line 7

def self.help(*args)
  super
  puts "Examples:\nholistics transforms list # List all data transformations\n\n"
end

Instance Method Details

#execute(id) ⇒ Object


37
38
39
40
41
42
# File 'lib/holistics/transforms.rb', line 37

def execute(id)
  puts "`transforms 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

#info(id) ⇒ Object


31
32
33
34
# File 'lib/holistics/transforms.rb', line 31

def info(id)
  puts "`transform info #{id}` called with options: #{options}" if Holistics.debug?
  tp(@this.find(id))
end

#list(ds_id = nil) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/holistics/transforms.rb', line 17

def list(ds_id = nil)
  puts "`transforms list` called with options: #{options}" if Holistics.debug?
  tp(
    @this.all.map do |item|
      item.slice(*%w{id title owner_name}).merge({
        mode: item['settings']['mode'],
        created_at: DateTime.parse(item['created_at']).to_formatted_s(:short),
        last_run: item['last_run'] ? DateTime.parse(item['last_run']).to_formatted_s(:short) : nil
      })
    end
  )
end