log_sense 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85b0ebee3c5879005dce7f3e32675a5f0319411eb74f138b2dfd7a4c21d26d43
4
- data.tar.gz: 1aec3ca221196cfaf9061495e6767f5136a23a1f9d6f510fb43a28c056c1ca8c
3
+ metadata.gz: 89f75b81840da58b73455053de50295235e5afa62a817e2b681000a768c7d71c
4
+ data.tar.gz: 792bd5927bd31e6af055e6515fcea976511cb195b86b915d998acbb05dec9050
5
5
  SHA512:
6
- metadata.gz: 27389b84f365fdaa02ece44dd70eabb130051ca81d26d17cd573325f8101d21c0dc83fd5c81915babfcd1e8d1f363ef777811f9676b2439e8f6b868013515700
7
- data.tar.gz: e52b3e05fb838362c3938aaf20d1f6347a3a4c8025d40963c98eeae4fe4b6c01d9acf225353ce2c872c213b2f113af089de418bc0e424e4b151884f4fd37c03c
6
+ metadata.gz: be7bee52c0951609c0c2398e86ac7c93e4b670950e593d9962a57f7f2566fbfcf9baa438b03bc9bf06c89c84be5dd45e1e68b642ee7a453edb63bebad40131d8
7
+ data.tar.gz: 596d1a6daf73b5c1b80a404abcf4c7cefc6e6faf8432c2e24036f2a9e00e6861b21d66fd377d4627807a0a627f9add9aea0995c641478110bcadb34ff2c9d209
data/CHANGELOG.org CHANGED
@@ -2,6 +2,15 @@
2
2
  #+AUTHOR: Adolfo Villafiorita
3
3
  #+STARTUP: showall
4
4
 
5
+ * 2.5.2
6
+
7
+ - Fixes a bug in the computation of total events in the Queries/Summary
8
+ report
9
+
10
+ * 2.5.1
11
+
12
+ - Add number of events in SQL queries
13
+
5
14
  * 2.5.0
6
15
 
7
16
  - Add query reports
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_sense (2.3.1)
4
+ log_sense (2.5.1)
5
5
  browser (~> 6.0.0)
6
6
  csv
7
7
  ipaddr (~> 1.2.0)
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LogSense
4
+ module FormattingUtil
5
+ ##
6
+ # Number with thousand separator
7
+ #
8
+ def self.with_thousands(number, separator: ",", comma: ".")
9
+ return unless number
10
+
11
+ decimal, fraction = number.to_s.split(comma)
12
+ with_thousands = decimal.reverse.gsub(/(\d\d\d)/, "\\1#{separator}")
13
+
14
+ "#{with_thousands.reverse}#{comma if fraction}#{fraction}"
15
+ end
16
+ end
17
+ end
@@ -5,6 +5,9 @@ module LogSense
5
5
  class RailsAggregator < Aggregator
6
6
  WORDS_SEPARATOR = ' · '
7
7
 
8
+ # with thousands
9
+ include LogSense::FormattingUtil
10
+
8
11
  def initialize(db, options = { limit: 900 })
9
12
  @table = "Event"
10
13
  @date_field = "started_at"
@@ -81,18 +84,26 @@ module LogSense
81
84
  }
82
85
  end
83
86
 
84
- @queries = @db.execute %Q(
85
- SELECT SUM(queries), SUM(cached_queries),
86
- ROUND(SUM(queries) / SUM(cached_queries), 2)
87
+ queries = @db.execute %Q(
88
+ SELECT COUNT(DISTINCT(id)), SUM(queries), SUM(cached_queries),
89
+ ROUND(1.0 * SUM(cached_queries) / SUM(queries), 2)
87
90
  FROM Event
88
91
  )
89
92
 
93
+ @queries = queries.map do |row|
94
+ row.map do |element|
95
+ FormattingUtil.with_thousands(element)
96
+ end
97
+ end
98
+
90
99
  @queries_by_controller = @db.execute %Q(
91
100
  SELECT controller,
92
- MIN(queries), MAX(queries), ROUND(AVG(queries), 2),
101
+ COUNT(DISTINCT(id)),
102
+ MIN(queries), MAX(queries),
103
+ ROUND(AVG(queries), 2),
93
104
  SUM(queries), SUM(cached_queries),
94
- ROUND(SUM(cached_queries) / SUM(queries), 2),
95
- SUM(gc_duration)
105
+ ROUND(1.0 * SUM(cached_queries) / SUM(queries), 2),
106
+ ROUND(SUM(gc_duration), 2)
96
107
  FROM Event
97
108
  GROUP BY Event.controller
98
109
  )
@@ -139,8 +139,8 @@ module LogSense
139
139
  def queries(data, colors: [], col: "small-12 cell")
140
140
  {
141
141
  title: "Number of queries",
142
- header: %w[Queries Cached Perc_Cached],
143
- column_alignment: %i[right right right],
142
+ header: %w[Events Queries Cached Perc_Cached],
143
+ column_alignment: %i[center center center center],
144
144
  rows: data[:queries],
145
145
  col: col,
146
146
  }
@@ -150,6 +150,7 @@ module LogSense
150
150
  {
151
151
  title: "Queries by Controller",
152
152
  header: ["Controller",
153
+ "Events",
153
154
  "Min queries", "Max queries", "Avg Queries",
154
155
  "Total queries", "Cached queries", "Perc",
155
156
  "Total GC"],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LogSense
4
- VERSION = "2.5.0"
4
+ VERSION = "2.5.2"
5
5
  end
data/lib/log_sense.rb CHANGED
@@ -6,6 +6,7 @@ require "log_sense/options/checker"
6
6
  require "log_sense/apache/log_parser"
7
7
  require "log_sense/rails/log_parser"
8
8
 
9
+ require "log_sense/formatting_util"
9
10
  require "log_sense/aggregator"
10
11
  require "log_sense/apache_aggregator"
11
12
  require "log_sense/rails_aggregator"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_sense
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita
@@ -196,6 +196,7 @@ files:
196
196
  - lib/log_sense/apache_aggregator.rb
197
197
  - lib/log_sense/apache_report_shaper.rb
198
198
  - lib/log_sense/emitter.rb
199
+ - lib/log_sense/formatting_util.rb
199
200
  - lib/log_sense/ip_locator.rb
200
201
  - lib/log_sense/options/checker.rb
201
202
  - lib/log_sense/options/parser.rb