Sha256: 388cb2a2b541d5e2859fd96c73e7a129104845863262b0d8d1092a86cad7bd17

Contents?: true

Size: 869 Bytes

Versions: 16

Compression:

Stored size: 869 Bytes

Contents

# frozen_string_literal: true

require "terminal-table"

module RubyPgExtras
  class TableInfoPrint
    def self.call(data)
      new.call(data)
    end

    def call(data)
      rows = data.map do |el|
        [
          el.fetch(:table_name),
          el.fetch(:table_size),
          el.fetch(:table_cache_hit),
          el.fetch(:indexes_cache_hit),
          el.fetch(:estimated_rows),
          el.fetch(:sequential_scans),
          el.fetch(:indexes_scans),
        ]
      end

      puts Terminal::Table.new(
        headings: [
          "Table name",
          "Table size",
          "Table cache hit",
          "Indexes cache hit",
          "Estimated rows",
          "Sequential scans",
          "Indexes scans",
        ],
        title: title,
        rows: rows,
      )
    end

    private

    def title
      "Table info"
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby-pg-extras-5.6.7 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.6 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.5 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.4 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.3 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.2 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.6.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.5.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.5.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.5 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.4 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.3 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.2 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.4.0 lib/ruby_pg_extras/table_info_print.rb