Sha256: dc5b438cc40c3ac53197a8bec531c349d2c051ee8f4719e3e1b946c929851297

Contents?: true

Size: 764 Bytes

Versions: 9

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true

require 'terminal-table'

module RubyPGExtras
  class IndexInfoPrint
    def self.call(data)
      new.call(data)
    end

    def call(data)
      rows = data.map do |el|
        [
          el.fetch(:index_name),
          el.fetch(:table_name),
          el.fetch(:columns).join(', '),
          el.fetch(:index_size),
          el.fetch(:index_scans),
          el.fetch(:null_frac)
        ]
      end

      puts Terminal::Table.new(
        headings: [
          "Index name",
          "Table name",
          "Columns",
          "Index size",
          "Index scans",
          "Null frac"
        ],
        title: title,
        rows: rows
      )
    end

    private

    def title
      "Index info"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ruby-pg-extras-3.3.0 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.7 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.6 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.5 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.4 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.3 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.2 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.1 lib/ruby-pg-extras/index_info_print.rb
ruby-pg-extras-3.2.0 lib/ruby-pg-extras/index_info_print.rb