Class: Apartment::Migrator::MigrationRun

Inherits:
Data
  • Object
show all
Defined in:
lib/apartment/migrator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results

Returns:

  • (Object)

    the current value of results



17
18
19
# File 'lib/apartment/migrator.rb', line 17

def results
  @results
end

#threadsObject (readonly)

Returns the value of attribute threads

Returns:

  • (Object)

    the current value of threads



17
18
19
# File 'lib/apartment/migrator.rb', line 17

def threads
  @threads
end

#total_durationObject (readonly)

Returns the value of attribute total_duration

Returns:

  • (Object)

    the current value of total_duration



17
18
19
# File 'lib/apartment/migrator.rb', line 17

def total_duration
  @total_duration
end

Instance Method Details

#failedObject



23
# File 'lib/apartment/migrator.rb', line 23

def failed    = results.select { _1.status == :failed }

#skippedObject



24
# File 'lib/apartment/migrator.rb', line 24

def skipped   = results.select { _1.status == :skipped }

#succeededObject



22
# File 'lib/apartment/migrator.rb', line 22

def succeeded = results.select { _1.status == :success }

#success?Boolean

Returns:

  • (Boolean)


25
# File 'lib/apartment/migrator.rb', line 25

def success?  = failed.empty?

#summaryObject

rubocop:disable Metrics/AbcSize



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/apartment/migrator.rb', line 27

def summary # rubocop:disable Metrics/AbcSize
  lines = []
  lines << "Migrated #{results.size} tenants in #{total_duration.round(1)}s (#{threads} threads)"
  lines << "  #{succeeded.size} succeeded" if succeeded.any?
  if failed.any?
    lines << "  #{failed.size} failed:"
    failed.each { |r| lines << "    #{r.tenant}: #{r.error&.class}: #{r.error&.message}" }
  end
  lines << "  #{skipped.size} skipped (up to date)" if skipped.any?
  lines.join("\n")
end