patronus_fati 1.1.0 → 1.1.1
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/patronus_fati/presence.rb +9 -1
- data/lib/patronus_fati/version.rb +1 -1
- data/spec/patronus_fati/presence_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10eb60457868f46c81ae5387c9df1c2762274426
|
4
|
+
data.tar.gz: 386a39bbc8dfee4a70096b765afc710c6472db4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda0ce738c8de86a5f9364e7471d48be1323434e7d97f8503b174c6268d6daf785a1f4a57ce211c476d4e1c57270339fd7586e335a7f39ef7a73c06317f5c871
|
7
|
+
data.tar.gz: a21660802b3f6cf4657df4718cde39171739aea24fbafb3711d066f00ccb8ef277c5263f7ccbe7a6dc31078f40934322e83fe8e68f2985b850a98bce12c9e1eb
|
@@ -71,7 +71,7 @@ module PatronusFati
|
|
71
71
|
def mark_visible
|
72
72
|
rotate_presence
|
73
73
|
|
74
|
-
|
74
|
+
set_first_seen unless first_seen
|
75
75
|
self.current_presence.set_bit(current_bit_offset)
|
76
76
|
end
|
77
77
|
|
@@ -87,6 +87,14 @@ module PatronusFati
|
|
87
87
|
self.current_presence = BitField.new(WINDOW_INTERVALS)
|
88
88
|
end
|
89
89
|
|
90
|
+
# Set the time we first saw whatever we're tracking to be the beginning of
|
91
|
+
# the current interval. This prevents negative durations in the event we
|
92
|
+
# only see it once.
|
93
|
+
def set_first_seen
|
94
|
+
cur_time = Time.now.to_i
|
95
|
+
self.first_seen = cur_time - (cur_time % INTERVAL_DURATION)
|
96
|
+
end
|
97
|
+
|
90
98
|
# Translate a bit into an absolute unix time relative to the reference
|
91
99
|
# window
|
92
100
|
def time_for_bit(reference_window, bit)
|
@@ -97,7 +97,7 @@ RSpec.describe(PatronusFati::Presence) do
|
|
97
97
|
end
|
98
98
|
|
99
99
|
it 'should set the first_seen timestamp if it hasn\'t been seen yet' do
|
100
|
-
expect { subject.mark_visible }.to change { subject.first_seen }.from(nil)
|
100
|
+
expect { subject.mark_visible }.to change { subject.first_seen }.from(nil)
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should not modify the first_seen timestamp if it has already been set' do
|