weathercock 1.2.0 → 1.3.0
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/CHANGELOG.md +10 -0
- data/README.md +4 -0
- data/lib/weathercock/key_builder.rb +6 -2
- data/lib/weathercock/scorer.rb +3 -1
- data/lib/weathercock/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3e7d0d33ec97370a0ec3fadd5c5660ed904fac4d53ac61b4f15f2ef896d86a0
|
|
4
|
+
data.tar.gz: 4afa58c886959543dcff63c906be312e2e89997aef099d48bea71a00c117696c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e81b1b7dc020df60de5d0cc9428ea8816f8b8fbfe90c7b8f5a32e195356579e29205b32beab2633e912d87b0fe4e9a57fb3b573974666d74d8ea7df671fb09ab
|
|
7
|
+
data.tar.gz: 81a3b745b52805b80977c8e36e0502c606bf94142feb14d6b30ae87c5563a1fcd7e0c18067fe70ee878ec2de0326d8ba331fc9fe793c71317f28f104bed2c780
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v1.3.0 - 2026-09-18
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Time-bucketed keys now prefer `Time.current` (when ActiveSupport is loaded) over `Time.now`, so bucket boundaries follow the application's configured time zone instead of each host's TZ
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Daily window keys are now built by calendar-day arithmetic; elapsed-seconds arithmetic could skip a date around a DST transition
|
|
12
|
+
|
|
3
13
|
## v1.2.0 - 2026-09-16
|
|
4
14
|
|
|
5
15
|
### Changed
|
data/README.md
CHANGED
|
@@ -21,6 +21,10 @@ Weathercock.configure do |c|
|
|
|
21
21
|
end
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
### Time zone
|
|
25
|
+
|
|
26
|
+
Time-bucketed keys are built from `Time.current` when it is available (i.e. ActiveSupport is loaded), so in a Rails app bucket boundaries follow `config.time_zone` regardless of each host's `TZ` setting. Outside Rails, `Time.now` (system time zone) is used.
|
|
27
|
+
|
|
24
28
|
### Tracking
|
|
25
29
|
|
|
26
30
|
Include `Weathercock::Scorable` in any class that has an `id`:
|
|
@@ -26,12 +26,16 @@ module Weathercock
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def window_keys(base, type, count)
|
|
29
|
-
|
|
29
|
+
# Time.current (ActiveSupport) follows the app-configured time zone, so
|
|
30
|
+
# bucket boundaries do not depend on each host's TZ setting.
|
|
31
|
+
now = Time.respond_to?(:current) ? Time.current : Time.now # steep:ignore NoMethod
|
|
30
32
|
case type
|
|
31
33
|
when :hours
|
|
32
34
|
count.times.map { |i| bucket(base, type, now - (i * 3600)) }
|
|
33
35
|
when :days
|
|
34
|
-
|
|
36
|
+
# now - i * 86400 would skip a date around a DST transition
|
|
37
|
+
today = now.to_date
|
|
38
|
+
count.times.map { |i| bucket(base, type, today - i) }
|
|
35
39
|
when :months
|
|
36
40
|
d = Date.new(now.year, now.month)
|
|
37
41
|
count.times.map { |i| bucket(base, type, d << i) }
|
data/lib/weathercock/scorer.rb
CHANGED
|
@@ -16,7 +16,9 @@ module Weathercock
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def hit(id, event, increment: 1)
|
|
19
|
-
|
|
19
|
+
# Time.current (ActiveSupport) follows the app-configured time zone, so
|
|
20
|
+
# bucket boundaries do not depend on each host's TZ setting.
|
|
21
|
+
now = Time.respond_to?(:current) ? Time.current : Time.now # steep:ignore NoMethod
|
|
20
22
|
base = @key_builder.base(event)
|
|
21
23
|
|
|
22
24
|
@redis.pipelined do |p|
|
data/lib/weathercock/version.rb
CHANGED