Class: SqlReporter::Query
- Inherits:
-
Object
- Object
- SqlReporter::Query
- Defined in:
- lib/sql_reporter/query.rb
Instance Attribute Summary collapse
-
#cached_count ⇒ Object
Returns the value of attribute cached_count.
-
#count ⇒ Object
Returns the value of attribute count.
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#sql ⇒ Object
Returns the value of attribute sql.
Class Method Summary collapse
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #duration_formatted ⇒ Object
-
#initialize(s, c, d, cc) ⇒ Query
constructor
A new instance of Query.
- #post_decimal_score(max_count) ⇒ Object
Constructor Details
#initialize(s, c, d, cc) ⇒ Query
Returns a new instance of Query.
12 13 14 15 16 17 |
# File 'lib/sql_reporter/query.rb', line 12 def initialize(s, c, d, cc) @sql = s @count = c @duration = d @cached_count = cc end |
Instance Attribute Details
#cached_count ⇒ Object
Returns the value of attribute cached_count.
6 7 8 |
# File 'lib/sql_reporter/query.rb', line 6 def cached_count @cached_count end |
#count ⇒ Object
Returns the value of attribute count.
6 7 8 |
# File 'lib/sql_reporter/query.rb', line 6 def count @count end |
#duration ⇒ Object
Returns the value of attribute duration.
6 7 8 |
# File 'lib/sql_reporter/query.rb', line 6 def duration @duration end |
#sql ⇒ Object
Returns the value of attribute sql.
6 7 8 |
# File 'lib/sql_reporter/query.rb', line 6 def sql @sql end |
Class Method Details
.null(query_name) ⇒ Object
8 9 10 |
# File 'lib/sql_reporter/query.rb', line 8 def self.null(query_name) self.new(query_name, 0, 0, 0) end |
Instance Method Details
#+(other) ⇒ Object
19 20 21 |
# File 'lib/sql_reporter/query.rb', line 19 def +(other) self.class.new(sql, count + other.count, duration + other.duration, cached_count + other.cached_count) end |
#-(other) ⇒ Object
23 24 25 |
# File 'lib/sql_reporter/query.rb', line 23 def -(other) self.class.new(sql, count - other.count, duration - other.duration, cached_count - other.cached_count) end |
#duration_formatted ⇒ Object
31 32 33 |
# File 'lib/sql_reporter/query.rb', line 31 def duration_formatted duration&.round(2) end |
#post_decimal_score(max_count) ⇒ Object
27 28 29 |
# File 'lib/sql_reporter/query.rb', line 27 def post_decimal_score(max_count) count * (1 / (max_count + 1)) end |