Sha256: b5dbb30a449cbedd24b741e9ae122f8ce6df70c60f54aceda5cd6799dd793c33

Contents?: true

Size: 1.61 KB

Versions: 12

Compression:

Stored size: 1.61 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2018 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

module GoodData
  module LCM2
    class Helpers
      DEFAULT_TABLE_NAME = 'LCM_RELEASE'
      DEFAULT_NFS_DIRECTORY = 'release-tables'

      class << self
        def latest_master_project_from_ads(release_table_name, ads_client, segment_id)
          replacements = {
            table_name: release_table_name || DEFAULT_TABLE_NAME,
            segment_id: segment_id
          }

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

          res = ads_client.execute_select(query)
          sorted = res.sort_by { |row| row[:version] }
          sorted.last
        end

        def latest_master_project_from_nfs(domain_id, segment_id)
          data = GoodData::Helpers::Csv.read_as_hash(path_to_release_table_file(domain_id, segment_id))
          data.sort_by { |master| master[:version] }
              .reverse.first
        end

        def update_latest_master_to_nfs(domain_id, segment_id, master_pid, version)
          GoodData::Helpers::Csv.ammend_line(
            path_to_release_table_file(domain_id, segment_id),
            master_project_id: master_pid,
            version: version
          )
        end

        def path_to_release_table_file(domain_id, segment_id)
          [DEFAULT_NFS_DIRECTORY, domain_id, segment_id + '.csv'].join('/')
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
gooddata-2.1.8-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.8 lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.7-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.7 lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.6-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.6 lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.5-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.5 lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.4-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.4 lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.3-java lib/gooddata/lcm/helpers/release_table_helper.rb
gooddata-2.1.3 lib/gooddata/lcm/helpers/release_table_helper.rb