counterwise 0.1.7 → 0.1.8
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/README.md +1 -1
- data/app/models/concerns/counter/verifyable.rb +14 -10
- data/lib/counter/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: 98ea12fd31d7f6fbf9d9e1c11c682825ff8f713558d50f6c16033251f8bc33af
|
|
4
|
+
data.tar.gz: 763508e600c386bbe73c8734619944bb9fbfd2081ee8315fadb1c2ac5fe83178
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cadb970d0a22154e6d2b38fe2b6a3573ea08812d966af0f6021bd7c9e52d7056a4a692cd768fa984fe666fcf0d7397d081b9f7cb1252650f37a6c5921e1a165b
|
|
7
|
+
data.tar.gz: f7c519035c5c1ad238827d6b70121537e983100c0150e29b9686fc8db15d6e1b72c3a89a0f9e306ec787d5fd1b1492cc3ee824488667f3a3dd7c05f18649b4fe
|
data/README.md
CHANGED
|
@@ -481,7 +481,7 @@ See the asociated project in Github but roughly I'm thinking:
|
|
|
481
481
|
|
|
482
482
|
Bug reports and pull requests are welcome, especially around naming, internal APIs, bug fixes, and additional features. Please open an issue first if you're thinking of adding a new feature so we can discuss it.
|
|
483
483
|
|
|
484
|
-
I'm unlikely to entertain
|
|
484
|
+
I'm unlikely to entertain support for older Ruby or Rails versions, or databases other than Postgres.
|
|
485
485
|
|
|
486
486
|
## License
|
|
487
487
|
|
|
@@ -2,25 +2,29 @@ module Counter::Verifyable
|
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
3
|
|
|
4
4
|
def correct?
|
|
5
|
-
# We can't verify these values
|
|
6
|
-
|
|
5
|
+
# We can't verify these values: manual counters (which includes globals)
|
|
6
|
+
# have no countable source of truth, so their stored value is authoritative.
|
|
7
|
+
return true if definition.manual?
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
correct_value, current_value = verify
|
|
10
|
+
correct_value == current_value
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def correct!
|
|
13
|
-
# We can't verify these values
|
|
14
|
-
|
|
14
|
+
# We can't verify these values: manual counters (which includes globals)
|
|
15
|
+
# have no countable source of truth, so their stored value is authoritative.
|
|
16
|
+
return true if definition.manual?
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
correct_value, current_value = verify
|
|
17
19
|
|
|
18
|
-
requires_recalculation =
|
|
19
|
-
update! value:
|
|
20
|
+
requires_recalculation = correct_value != current_value
|
|
21
|
+
update! value: correct_value if requires_recalculation
|
|
20
22
|
|
|
21
23
|
!requires_recalculation
|
|
22
24
|
end
|
|
23
25
|
|
|
26
|
+
# Returns [correct_value, current_value]: the value recomputed from live
|
|
27
|
+
# data, and the value currently stored on the counter.
|
|
24
28
|
def verify
|
|
25
29
|
if definition.calculated?
|
|
26
30
|
[calculate, value]
|
|
@@ -43,7 +47,7 @@ module Counter::Verifyable
|
|
|
43
47
|
counter = counters.where("id >= ?", random_id).limit(1).first
|
|
44
48
|
next if counter.nil?
|
|
45
49
|
|
|
46
|
-
if counter.definition.
|
|
50
|
+
if counter.definition.manual? || counter.definition.calculated?
|
|
47
51
|
puts "➡️ Skipping counter #{counter.name} (#{counter.id})" if verbose
|
|
48
52
|
next
|
|
49
53
|
end
|
data/lib/counter/version.rb
CHANGED