Sha256: 73a907a019616640f084be0ce06bbdf98fe6d33a2a8b1192a09282eb36573d4f

Contents?: true

Size: 767 Bytes

Versions: 10

Compression:

Stored size: 767 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

10 entries across 10 versions & 1 rubygems

Version Path
ruby-pg-extras-5.6.1 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.6.0 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.5.1 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.5.0 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.5 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.4 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.3 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.2 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.1 lib/ruby_pg_extras/index_info_print.rb
ruby-pg-extras-5.4.0 lib/ruby_pg_extras/index_info_print.rb