twistage_stats_reports 1.0.3 → 1.0.4

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
  SHA1:
3
- metadata.gz: 1a174e7f50c6a5948d47dafbf59f71b277ca9150
4
- data.tar.gz: 9b1c2d8b806f352975534e516140c73bf3026c26
3
+ metadata.gz: 96843d61c0c780f737a4c7c3ce988393280e776a
4
+ data.tar.gz: 36948d681790a554129f74230c7d0c05b3e958bd
5
5
  SHA512:
6
- metadata.gz: f7b44606651b0ded7bd8bc507133b220ede93030c0fba5f337b6be9843a306d88b5cddbdf93e741b40fa5f98003d6009e626af54b9ef4af8c7a165cbbe928cfc
7
- data.tar.gz: 6aff140e7bf86f6843674f5a3c5591619b6c11fdc35e8f303d2378fd1852f8a579fb1c5050f2d9fcfc0b3750a082840693fb7fd4e28392b0e1277fc8ec0c4de6
6
+ metadata.gz: fd27c7b461a3b8216faae98c2780bffd69d37bbd3652b23f1a57f351b754b36912d1a5b6e4c85e8341844306db91016d634e56b5dcc45f4db3243d9b7b85827c
7
+ data.tar.gz: 12badcab2c97c31f7cac569c1533490fc150841556fbc14011bff3bcad98c9c9e079c5f3fce1b5ff06a470b5a481fa4648f2eed0e082c62edbe82fef0aa30853
@@ -14,11 +14,11 @@ class Stats::BreakdownReport < Stats::EventReport
14
14
 
15
15
  @query_time = nil
16
16
 
17
- @duration_uploaded = ('%.2f' % (options[:duration_uploaded].to_f || 0)).to_f
18
- @duration_uploaded_min = ('%.2f' % (@duration_uploaded / 60.seconds.to_f)).to_f
17
+ @duration_uploaded = self.class.format_duration(options[:duration_uploaded].to_f || 0)
18
+ @duration_uploaded_min = self.class.format_duration(@duration_uploaded / 60.seconds.to_f)
19
19
 
20
- @duration_encoded = ('%.2f' % (options[:duration_encoded].to_f || 0)).to_f
21
- @duration_encoded_min = ('%.2f' % (@duration_encoded / 60.seconds.to_f)).to_f
20
+ @duration_encoded = self.class.format_duration(options[:duration_encoded].to_f || 0)
21
+ @duration_encoded_min = self.class.format_duration(@duration_encoded / 60.seconds.to_f)
22
22
  end
23
23
 
24
24
  def self.csv_keys
@@ -19,6 +19,9 @@ class Stats::EventReport < Stats::Report
19
19
  :bytes_transferred => %w[profile],
20
20
  }
21
21
 
22
+ PRECISION_DURATION = 2
23
+ PRECISION_GB = 2
24
+
22
25
  set_attributes [ :id, :date, :start_date, :end_date, :title, :label, :name, :query_time, :stats_type ]
23
26
  set_numeric_attributes [ :hits, :plays, :downloads, :bytes_transferred]
24
27
 
@@ -340,6 +343,18 @@ class Stats::EventReport < Stats::Report
340
343
  title_value
341
344
  end
342
345
 
346
+ def self.format_float(value, precision)
347
+ value.round(precision)
348
+ end
349
+
350
+ def self.format_duration(value)
351
+ format_float(value, PRECISION_DURATION)
352
+ end
353
+
354
+ def self.format_gb(value)
355
+ format_float(value, PRECISION_GB)
356
+ end
357
+
343
358
  private
344
359
 
345
360
  def strip_keys_by_label(the_keys, label)
@@ -21,16 +21,16 @@ class Stats::PublishReport < Stats::EventReport
21
21
  @query_time = nil
22
22
 
23
23
  @bytes_uploaded = options[:bytes_uploaded]
24
- @bytes_uploaded_gb = ('%.2f' % (options[:bytes_uploaded] / 1.gigabyte.to_f)).to_f
24
+ @bytes_uploaded_gb = self.class.format_gb(options[:bytes_uploaded] / 1.gigabyte.to_f)
25
25
 
26
26
  @bytes_encoded = options[:bytes_encoded]
27
- @bytes_encoded_gb = ('%.2f' % (options[:bytes_encoded] / 1.gigabyte.to_f)).to_f
27
+ @bytes_encoded_gb = self.class.format_gb(options[:bytes_encoded] / 1.gigabyte.to_f)
28
28
 
29
- @duration_uploaded = ('%.2f' % options[:duration_uploaded]).to_f
30
- @duration_uploaded_min = ('%.2f' % (options[:duration_uploaded] / 60.seconds.to_f)).to_f
29
+ @duration_uploaded = self.class.format_duration(options[:duration_uploaded])
30
+ @duration_uploaded_min = self.class.format_duration(options[:duration_uploaded] / 60.seconds.to_f)
31
31
 
32
- @duration_encoded = ('%.2f' % options[:duration_encoded]).to_f
33
- @duration_encoded_min = ('%.2f' % (options[:duration_encoded] / 60.seconds.to_f)).to_f
32
+ @duration_encoded = self.class.format_duration(options[:duration_encoded])
33
+ @duration_encoded_min = self.class.format_duration(options[:duration_encoded] / 60.seconds.to_f)
34
34
  end
35
35
 
36
36
  def self.csv_keys
@@ -9,8 +9,8 @@ class Stats::SourceReport < Stats::EventReport
9
9
  @publish_type = options[:publish_type]
10
10
  @publishes = options[:publishes] || 0
11
11
  @query_time = nil
12
- @duration = ('%.2f' % (options[:duration] || 0)).to_f
13
- @duration_min = ('%.2f' % (@duration / 60.seconds.to_f)).to_f
12
+ @duration = self.class.format_duration(options[:duration] || 0)
13
+ @duration_min = self.class.format_duration(@duration / 60.seconds.to_f)
14
14
  end
15
15
 
16
16
  def self.csv_keys
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twistage_stats_reports
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Wegman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Shared data structures and logic for interacting with the Twistage Stats
14
14
  service