shiba_stats 0.0.2 → 0.0.3

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: 55a9bc417e091c94a0e6c9a598573bdae76f219bb5d5251e6db814cfbbd79349
4
- data.tar.gz: 4ff7e1648ed6be0b3245dc52121e74511a118f612de88de584125ff9b13ae0ab
3
+ metadata.gz: bc0addf596e9ca9f0a6f2cee7de1dc2e69d7e15554a7bdcf4300750acc274d7c
4
+ data.tar.gz: ed1cd26cbf402427f94810e7c9624d7a94bbb2355d9740c74899a44cc2a0fd92
5
5
  SHA512:
6
- metadata.gz: 34c44de14c71f5dc640a675f3deb2cdaed55268f7bfbde9b14ec0fdd5200147a5e7991e369015709a02534d98f22ff8e2e79ddc7086ada2da0770d96a5d76f11
7
- data.tar.gz: e8f66428568d8dff9741d18a454e337ee1fed7f92bdc9c3c99ba6d2b051cc3d8ba03b330de6bae9613b9ae186a210126f0a97a78349eec89a76e9f887c38db05
6
+ metadata.gz: '09b36c6e8207c6b512e5123f824923219490fe6666c7f71adb463f9a9ab62724f1aef10939890b9b1c73de5971e1881bcdfeba47c749d89e513fa965c08e6c75'
7
+ data.tar.gz: cb8d92eb4946bae0f9f57e511c33e41710adc07fb19a5e12e440e9b4f5221670bea9ed82bd93dbe789aaa36601b2d395ef0c3accb35672f6ed764069e4e63f2a
data/lib/shiba_stats.rb CHANGED
@@ -3,8 +3,7 @@ require 'shiba_stats_helper'
3
3
  class ShibaStats
4
4
  ActionView::Base.send :include, ShibaStatsHelper
5
5
 
6
-
7
- def self.add(key, amount = 1)
6
+ def self.add(key, amount)
8
7
  time_series(key).add(amount)
9
8
  end
10
9
 
@@ -1,5 +1,5 @@
1
1
  module ShibaStatsHelper
2
-
2
+
3
3
  def shiba_line(keys, chart_options = {}, options = {})
4
4
  line_chart prepare_data(keys, options), **chart_options
5
5
  end
@@ -22,10 +22,15 @@ module ShibaStatsHelper
22
22
  data = []
23
23
  options[:start_time] ||= Time.zone.now - 24.hours
24
24
  options[:end_time] ||= Time.zone.now
25
+ options[:aggregation_period] ||= 1.minute
26
+ options[:aggregation_type] ||= :count
25
27
 
26
28
  keys.each do |key|
27
29
  key_data = { name: key, data: {}}
28
- time_series = ShibaStats.time_series(key).range(options[:start_time]..options[:end_time], aggregation: [:count, 1.seconds])
30
+ time_series = ShibaStats.time_series(key).range(
31
+ options[:start_time]..options[:end_time],
32
+ aggregation: [options[:aggregation_type], options[:aggregation_period]]
33
+ )
29
34
  time_series.each do |point|
30
35
  key_data[:data][point.time] = point.value
31
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shiba_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will DeWind
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-04 00:00:00.000000000 Z
11
+ date: 2022-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick