Class: RailsConsolePro::StatsResult
- Inherits:
-
Object
- Object
- RailsConsolePro::StatsResult
- Defined in:
- lib/rails_console_pro/stats_result.rb
Overview
Value object for model statistics
Instance Attribute Summary collapse
-
#column_stats ⇒ Object
readonly
Returns the value of attribute column_stats.
-
#growth_rate ⇒ Object
readonly
Returns the value of attribute growth_rate.
-
#index_usage ⇒ Object
readonly
Returns the value of attribute index_usage.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#record_count ⇒ Object
readonly
Returns the value of attribute record_count.
-
#table_size ⇒ Object
readonly
Returns the value of attribute table_size.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#export_to_file(file_path, format: nil) ⇒ Object
Export to file.
- #has_growth_data? ⇒ Boolean
- #has_index_data? ⇒ Boolean
- #has_table_size? ⇒ Boolean
-
#initialize(model:, record_count:, growth_rate: nil, table_size: nil, index_usage: {}, column_stats: {}, timestamp: Time.current) ⇒ StatsResult
constructor
A new instance of StatsResult.
-
#to_html(style: :default) ⇒ Object
Export to HTML.
-
#to_json(pretty: true) ⇒ Object
Export to JSON.
-
#to_yaml ⇒ Object
Export to YAML.
Constructor Details
#initialize(model:, record_count:, growth_rate: nil, table_size: nil, index_usage: {}, column_stats: {}, timestamp: Time.current) ⇒ StatsResult
Returns a new instance of StatsResult.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rails_console_pro/stats_result.rb', line 9 def initialize(model:, record_count:, growth_rate: nil, table_size: nil, index_usage: {}, column_stats: {}, timestamp: Time.current) @model = model @record_count = record_count @growth_rate = growth_rate @table_size = table_size @index_usage = index_usage @column_stats = column_stats = validate_model! end |
Instance Attribute Details
#column_stats ⇒ Object (readonly)
Returns the value of attribute column_stats.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def column_stats @column_stats end |
#growth_rate ⇒ Object (readonly)
Returns the value of attribute growth_rate.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def growth_rate @growth_rate end |
#index_usage ⇒ Object (readonly)
Returns the value of attribute index_usage.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def index_usage @index_usage end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def model @model end |
#record_count ⇒ Object (readonly)
Returns the value of attribute record_count.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def record_count @record_count end |
#table_size ⇒ Object (readonly)
Returns the value of attribute table_size.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def table_size @table_size end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/rails_console_pro/stats_result.rb', line 6 def end |
Instance Method Details
#==(other) ⇒ Object
21 22 23 |
# File 'lib/rails_console_pro/stats_result.rb', line 21 def ==(other) other.is_a?(self.class) && other.model == model && other. == end |
#export_to_file(file_path, format: nil) ⇒ Object
Export to file
53 54 55 |
# File 'lib/rails_console_pro/stats_result.rb', line 53 def export_to_file(file_path, format: nil) FormatExporter.export_to_file(self, file_path, format: format) end |
#has_growth_data? ⇒ Boolean
25 26 27 |
# File 'lib/rails_console_pro/stats_result.rb', line 25 def has_growth_data? !growth_rate.nil? end |
#has_index_data? ⇒ Boolean
33 34 35 |
# File 'lib/rails_console_pro/stats_result.rb', line 33 def has_index_data? index_usage.any? end |
#has_table_size? ⇒ Boolean
29 30 31 |
# File 'lib/rails_console_pro/stats_result.rb', line 29 def has_table_size? !table_size.nil? end |
#to_html(style: :default) ⇒ Object
Export to HTML
48 49 50 |
# File 'lib/rails_console_pro/stats_result.rb', line 48 def to_html(style: :default) FormatExporter.to_html(self, title: "Statistics: #{model.name}", style: style) end |
#to_json(pretty: true) ⇒ Object
Export to JSON
38 39 40 |
# File 'lib/rails_console_pro/stats_result.rb', line 38 def to_json(pretty: true) FormatExporter.to_json(self, pretty: pretty) end |
#to_yaml ⇒ Object
Export to YAML
43 44 45 |
# File 'lib/rails_console_pro/stats_result.rb', line 43 def to_yaml FormatExporter.to_yaml(self) end |