apache_log_report 0.9.8 → 0.9.9

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: 77ddb670e22eb7d75ebd658beecb96a452b9c65ace149f2a8376921271063d84
4
- data.tar.gz: 33f6690db108ac0c4d9f8619f90add9ec5f9ac4d5414b38127413ea618b8e46f
3
+ metadata.gz: 0cfcc34ca8741250adff411009618f4a359c4c59606a911a924416650fa352e7
4
+ data.tar.gz: 4f366f09084266e0112f597aac8be998ff47df8ef50d8fd01b1c26361dc889b9
5
5
  SHA512:
6
- metadata.gz: f8074e3498f0b8f5e8769f5fccade340cb85f7bfa8dc5393197d216b1f22329bd14484c0ab45e5dcfa11f5dd26f007dbd44fa666273e1e50a14cbfdfa5c835ba
7
- data.tar.gz: fda701c90b667b09d6a385ab23da6a10725624256cb92eb9521f53b119bf461a1a147db6fb6cb1b191dfcf874b920852fdb13c5f125f38f788657e8b9c8a6c9e
6
+ metadata.gz: ddee7b7b3fd56327c3409f0a6de2778b83a0e67d743d300f00259ba314159d1cb62315f388fc0136052895903c7e6df47e08ba59b036db23f0722fc99e5f7b6d
7
+ data.tar.gz: 0e857dbb34cd66057a401016afcd457c19c995c7aff66a87d4db230569b67a091c19d5f3446377f1a7ee8f8cda3b70ea0b8b4753bd7aea3beadc07810cf2d54b
@@ -18,11 +18,11 @@ module ApacheLogReport
18
18
  args[:limit] = n
19
19
  end
20
20
 
21
- opts.on("-bDATE", "--from-date=DATE", DateTime, "Consider entries after or on DATE") do |n|
21
+ opts.on("-bDATE", "--begin=DATE", DateTime, "Consider entries after or on DATE") do |n|
22
22
  args[:from_date] = n
23
23
  end
24
24
 
25
- opts.on("-eDATE", "--to-date=DATE", DateTime, "Consider entries before or on DATE") do |n|
25
+ opts.on("-eDATE", "--end=DATE", DateTime, "Consider entries before or on DATE") do |n|
26
26
  args[:to_date] = n
27
27
  end
28
28
 
@@ -186,18 +186,29 @@ module ApacheLogReport
186
186
  "true"
187
187
  ].compact.join " and "
188
188
 
189
+ # in alternative to sum(size)
190
+ human_readable_size = <<-EOS
191
+ CASE
192
+ WHEN sum(size) < 1024 THEN sum(size) || ' B'
193
+ WHEN sum(size) >= 1024 AND sum(size) < (1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / 1024),2) || ' KB'
194
+ WHEN sum(size) >= (1024 * 1024) AND sum(size) < (1024 * 1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024)),2) || ' MB'
195
+ WHEN sum(size) >= (1024 * 1024 * 1024) AND sum(size) < (1024 * 1024 * 1024 *1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024 * 1024)),2) || ' GB'
196
+ WHEN sum(size) >= (1024 * 1024 * 1024 * 1024) THEN ROUND((CAST(sum(size) AS REAL) / (1024 * 1024 * 1024 * 1024)),2) || ' TB'
197
+ END AS size
198
+ EOS
199
+
189
200
  @total_hits = db.execute "SELECT count(datetime) from LogLine where #{@filter}"
190
201
  @total_unique_visitors = db.execute "SELECT count(distinct(unique_visitor)) from LogLine where #{@filter}"
191
- @total_size = db.execute "SELECT sum(size) from LogLine where #{@filter}"
202
+ @total_size = db.execute "SELECT #{human_readable_size} from LogLine where #{@filter}"
192
203
  @total_days = (Date.parse(@last_day[0][0]) - Date.parse(@first_day[0][0])).to_i
193
204
 
194
- @daily_distribution = db.execute "SELECT date(datetime), count(datetime), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by date(datetime)"
205
+ @daily_distribution = db.execute "SELECT date(datetime), count(datetime), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by date(datetime)"
195
206
 
196
- @time_distribution = db.execute "SELECT strftime('%H', datetime), count(datetime), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by strftime('%H', datetime)"
207
+ @time_distribution = db.execute "SELECT strftime('%H', datetime), count(datetime), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by strftime('%H', datetime)"
197
208
 
198
- @most_requested_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), sum(size) from LogLine where extension == '.html' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
209
+ @most_requested_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where extension == '.html' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
199
210
 
200
- @most_requested_resources = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
211
+ @most_requested_resources = db.execute "SELECT path, count(path), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
201
212
 
202
213
  @missed_pages = db.execute "SELECT path, count(path), count(distinct(unique_visitor)) from LogLine where status == '404' and extension == '.html' and #{@filter} group by path order by count(path) desc limit #{options[:limit]}"
203
214
 
@@ -219,13 +230,13 @@ module ApacheLogReport
219
230
  [x[0], x[1].map { |y| y[1] }].flatten
220
231
  }
221
232
 
222
- @browsers = db.execute "SELECT browser, count(browser), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by browser order by count(browser) desc"
233
+ @browsers = db.execute "SELECT browser, count(browser), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by browser order by count(browser) desc"
223
234
 
224
- @platforms = db.execute "SELECT platform, count(platform), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by platform order by count(platform) desc"
235
+ @platforms = db.execute "SELECT platform, count(platform), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by platform order by count(platform) desc"
225
236
 
226
- @ips = db.execute "SELECT ip, count(ip), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by ip order by count(ip) desc limit #{options[:limit]}"
237
+ @ips = db.execute "SELECT ip, count(ip), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by ip order by count(ip) desc limit #{options[:limit]}"
227
238
 
228
- @referers = db.execute "SELECT referer, count(referer), count(distinct(unique_visitor)), sum(size) from LogLine where #{@filter} group by referer order by count(referer) desc limit #{options[:limit]}"
239
+ @referers = db.execute "SELECT referer, count(referer), count(distinct(unique_visitor)), #{human_readable_size} from LogLine where #{@filter} group by referer order by count(referer) desc limit #{options[:limit]}"
229
240
  end
230
241
 
231
242
 
@@ -263,7 +274,7 @@ module ApacheLogReport
263
274
 
264
275
  | Hits | #{"%10d" % @total_hits[0][0]} |
265
276
  | Unique Visitors | #{"%10d" % @total_unique_visitors[0][0] } |
266
- | Tx | #{"%10d" % @total_size[0][0] } |
277
+ | Tx | #{"%10s" % @total_size[0][0]} |
267
278
  | Days | #{"%10d" % @total_days[0][0] } |
268
279
 
269
280
  * Daily Distribution
@@ -1,3 +1,3 @@
1
1
  module ApacheLogReport
2
- VERSION = "0.9.8"
2
+ VERSION = "0.9.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apache_log_report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita