shiba_stats 0.0.1 → 0.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 +4 -4
- data/lib/shiba_stats.rb +10 -3
- data/lib/shiba_stats_helper.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42e8b40db90a76b5107a9bf3f61119ab1576595cf66c9c95ba92cfaea1922853
|
4
|
+
data.tar.gz: 37a44bd986fba677efee8f5c500f2f305942ef0c2580f155b9d1345f4349440c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0f3792d91bddd0d6a836fe4002951faf55e98d24f8a19bc5a21b53f38dcf4f60f78a20a9b3444770aca9bd2d17e7daec875457ae452f410ebfb81c438227fb4
|
7
|
+
data.tar.gz: 66e51444e4a939f9117af09db0d191e68c66e098946971ff08c71ffdec466ceefc5fe6ead42159f8f16af263bc04314f5f9feff2805e0e2b878c2c6b9ae9cf8d
|
data/lib/shiba_stats.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
require 'shiba_stats_helper'
|
2
|
+
|
1
3
|
class ShibaStats
|
2
4
|
ActionView::Base.send :include, ShibaStatsHelper
|
3
5
|
|
4
|
-
|
5
|
-
def self.add(key, amount = 1)
|
6
|
+
def self.add(key, amount)
|
6
7
|
time_series(key).add(amount)
|
7
8
|
end
|
8
9
|
|
@@ -11,6 +12,12 @@ class ShibaStats
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.time_series(key)
|
14
|
-
Redis
|
15
|
+
redis ||= Redis.new(
|
16
|
+
:host => ENV["REDIS_HOST"],
|
17
|
+
:port => ENV["REDIS_PORT"],
|
18
|
+
:password => ENV["REDIS_PASSWORD"]
|
19
|
+
)
|
20
|
+
Redis::TimeSeries.new(key, redis: redis)
|
15
21
|
end
|
22
|
+
|
16
23
|
end
|
data/lib/shiba_stats_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module ShibaStatsHelper
|
2
|
+
|
2
3
|
def shiba_line(keys, chart_options = {}, options = {})
|
3
4
|
line_chart prepare_data(keys, options), **chart_options
|
4
5
|
end
|
@@ -21,10 +22,15 @@ module ShibaStatsHelper
|
|
21
22
|
data = []
|
22
23
|
options[:start_time] ||= Time.zone.now - 24.hours
|
23
24
|
options[:end_time] ||= Time.zone.now
|
25
|
+
options[:aggregation_period] ||= 1.minute
|
26
|
+
options[:aggregation_type] ||= :count
|
24
27
|
|
25
28
|
keys.each do |key|
|
26
29
|
key_data = { name: key, data: {}}
|
27
|
-
time_series = ShibaStats.time_series(key).range(
|
30
|
+
time_series = ShibaStats.time_series(key).range(
|
31
|
+
options[:start_time]..options[:end_time],
|
32
|
+
aggregation: [options[:aggregation_type], options[:aggregation_period]]
|
33
|
+
)
|
28
34
|
time_series.each do |point|
|
29
35
|
key_data[:data][point.time] = point.value
|
30
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.
|
4
|
+
version: 0.0.4
|
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-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|