Class: GoodData::LCM2::EnsureReleaseTable

Inherits:
BaseAction show all
Defined in:
lib/gooddata/lcm/actions/ensure_release_table.rb

Constant Summary collapse

DESCRIPTION =
'Ensures presence of LCM_RELEASE table'
PARAMS =
define_params(self) do
  description 'ADS Client'
  param :ads_client, instance_of(Type::AdsClientType), required: false

  description 'Table Name'
  param :release_table_name, instance_of(Type::StringType), required: false
end
RESULT_HEADER =
[
  :table_name,
  :status
]
DEFAULT_TABLE_NAME =
'LCM_RELEASE'

Constants inherited from BaseAction

BaseAction::FAILED_CLIENTS, BaseAction::FAILED_PROJECTS, BaseAction::FAILED_SEGMENTS, BaseAction::SYNC_FAILED_LIST

Constants included from Dsl::Dsl

Dsl::Dsl::DEFAULT_OPTS, Dsl::Dsl::TYPES

Class Method Summary collapse

Methods inherited from BaseAction

add_failed_client, add_failed_project, add_failed_segment, add_new_clients_to_project_client_mapping, check_params, collect_synced_status, continue_on_error, print_result, process_failed_project, process_failed_projects, sync_failed_client, sync_failed_project, sync_failed_segment, without_check

Methods included from Dsl::Dsl

#define_params, #define_type, #process

Class Method Details

.call(params) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/gooddata/lcm/actions/ensure_release_table.rb', line 30

def call(params)
  if params.ads_client
    replacements = {
      table_name: params.release_table_name || DEFAULT_TABLE_NAME
    }

    path = File.expand_path('../data/create_lcm_release.sql.erb', __dir__)
    query = GoodData::Helpers::ErbHelper.template_file(path, replacements)

    sql_result = params.ads_client.execute(query)

    # TODO: Format
    GoodData.logger.info(JSON.pretty_generate(sql_result))

    [
      {
        table_name: replacements[:table_name],
        status: 'ok'
      }
    ]
  else
    [
      {
        status: 'ok'
      }
    ]
  end
end