Sha256: cd5c39302b5aa3c9592baa2d8ef1eb5c23d9407a3a0d7429bb23be54bcb80838

Contents?: true

Size: 866 Bytes

Versions: 33

Compression:

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

33 entries across 33 versions & 1 rubygems

Version Path
ruby-pg-extras-5.3.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.3.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.5 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.4 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.3 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.2 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.2.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.1.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-5.0.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.13.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.12.2 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.12.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.12.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.11.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.10.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.9.0 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.8.1 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.7.2 lib/ruby_pg_extras/table_info_print.rb
ruby-pg-extras-4.7.1 lib/ruby_pg_extras/table_info_print.rb