Last active
August 19, 2021 12:17
-
-
Save bogdan/540979fbf03bd96960e6415f55fdd123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TablesStatsGrid < BaseDatagrid | |
scope do | |
[] | |
end | |
dynamic do | |
scope do | |
ActiveRecord::Base.connection.select_all("SHOW TABLE STATUS").to_ary | |
end | |
end | |
self.default_column_options = {order_by_value: true} | |
filter(:name) do |value, scope| | |
scope.select{|t| t['Name'].includes?(value)} | |
end | |
column(:name) do |asset| | |
asset['Name'] | |
end | |
column(:rows) do |asset| | |
asset['Rows'] | |
end | |
column(:row_size, header: 'Row Size') do |asset| | |
asset['Avg_row_length'] | |
end | |
column(:data_size, header: 'Data Size') do |asset| | |
format(asset['Data_length']) { |value| number_to_human_size(value) } | |
end | |
column(:index_size, header: 'Index Size') do |asset| | |
format(asset['Index_length']) { |value| number_to_human_size(value) } | |
end | |
column(:total_size, header: 'Total Size') do |asset| | |
asset['Total_length'] = asset['Data_length'].to_i + asset['Index_length'].to_i | |
format(asset['Total_length']) { |value| number_to_human_size(value) } | |
end | |
column(:comment) do |asset| | |
asset['Comment'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment