Method: GoodData::LCM2::MigrateGdcDateDimension.migrate_date_dimension

Defined in:
lib/gooddata/lcm/actions/migrate_gdc_date_dimension.rb

.migrate_date_dimension(params, segment_info) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/gooddata/lcm/actions/migrate_gdc_date_dimension.rb', line 53

def migrate_date_dimension(params, segment_info)
  results = []
  client = params.gdc_gd_client
  latest_blueprint = segment_info[:from_blueprint]
  # don't migrate when latest master doesn't contain custom v2 date.
  return results unless contain_v2?(latest_blueprint)

  previous_blueprint = segment_info[:previous_master]&.blueprint
  # check latest master and previous master
  master_upgrade_datasets = get_upgrade_dates(latest_blueprint, previous_blueprint) if params[:synchronize_ldm].downcase == 'diff_against_master' && previous_blueprint
  unless master_upgrade_datasets&.empty?
    collect_synced_status = collect_synced_status(params)
    failed_projects = ThreadSafe::Array.new

    segment_info[:to].pmap do |entry|
      pid = entry[:pid]
      next if sync_failed_project(pid, params)

      to_project = client.projects(pid) || fail("Invalid 'to' project specified - '#{pid}'")
      GoodData.logger.info "Migrating date dimension, project: '#{to_project.title}', PID: #{pid}"
      to_blueprint = to_project.blueprint
      upgrade_datasets = get_upgrade_dates(latest_blueprint, to_blueprint)
      next if upgrade_datasets.empty?

      message = get_upgrade_message(upgrade_datasets)
      failed_message = "Failed to migrate date dimension for project #{pid}"
      update_status = to_project.upgrade_custom_v2(message)
      process_failed_project(pid, failed_message, failed_projects, collect_synced_status) if collect_synced_status && update_status != 'OK'

      results << {
        from: segment_info[:from],
        to: pid,
        status: update_status
      }
    end

    process_failed_projects(failed_projects, short_name, params) if collect_synced_status
  end

  results
end