close_encounters 0.2.1 → 0.2.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 +4 -4
- data/CHANGELOG.md +7 -13
- data/lib/close_encounters/version.rb +1 -1
- data/lib/close_encounters.rb +25 -8
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67adeb4fe53671ebcc9e37f040245dd7650ec3afc83433e13415c290617ee356
|
4
|
+
data.tar.gz: e7afee308898aa7a25cf3ddfaa652369c74fdb074c014054ee37438babe0b714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0131dcd0a979e6bf3583fe3b90c91b597defbf0f660b8bfaaf2f8d2988a3b1714177148a6cec10078f1a69b8175de7c27d6bccc29523001264ca8c6f667e381
|
7
|
+
data.tar.gz: 117c8347983b35986897f55920c4d8472be867598901ca2e83bbf51f2560f083e8c6b9e27559f67c327faa66cbde30b93c1cdb19abd1e9356e792411992ff385
|
data/CHANGELOG.md
CHANGED
@@ -5,24 +5,18 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
-
## [0.2.
|
8
|
+
## [0.2.3] - 2025-09-08
|
9
9
|
|
10
|
-
###
|
10
|
+
### Fixed
|
11
11
|
|
12
|
-
-
|
13
|
-
- Add configuration for auto_contact and verify_scan_statuses.
|
12
|
+
- Fix duplicate event creation in `scan` method when status and verification state are unchanged
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
- Ensure that events are only created if the status has changed or if the status is in the verify_scan_statuses list and verification fails.
|
18
|
-
|
19
|
-
## [0.2.0] - 2025-02-26
|
14
|
+
## [0.2.2] - 2025-09-04
|
20
15
|
|
21
16
|
### Changed
|
22
17
|
|
23
|
-
-
|
18
|
+
- Update handling of the same status for multiple requests when creating events.
|
24
19
|
|
25
|
-
###
|
20
|
+
### Fixed
|
26
21
|
|
27
|
-
-
|
28
|
-
- Add metadata to events for storing extra information about the event.
|
22
|
+
- Ensure that status is an integer when creating events and comparing results.
|
data/lib/close_encounters.rb
CHANGED
@@ -31,8 +31,13 @@ module CloseEncounters
|
|
31
31
|
# @param response [String] the response object
|
32
32
|
def contact(name, status:, response:)
|
33
33
|
service = ParticipantService.find_by!(name:)
|
34
|
-
|
35
|
-
|
34
|
+
status = status.to_i # Ensure status is always an integer
|
35
|
+
|
36
|
+
# Use a transaction with a lock to prevent race conditions
|
37
|
+
service.with_lock do
|
38
|
+
unless service.events.newest.pick(:status) == status
|
39
|
+
service.events.create!(status: status, response:)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
|
@@ -49,14 +54,26 @@ module CloseEncounters
|
|
49
54
|
# @param verifier [Proc] the verification callable which must also respond to to_s
|
50
55
|
def scan(name, status:, response:, verifier:)
|
51
56
|
service = ParticipantService.find_by!(name:)
|
52
|
-
|
57
|
+
status = status.to_i # Ensure status is always an integer
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
service.with_lock do
|
60
|
+
last_event = service.events.newest.first
|
61
|
+
last_status = last_event&.status
|
62
|
+
last_verified = last_event&.verified?
|
63
|
+
|
64
|
+
# Calculate current verification result
|
58
65
|
verified = verifier.call(response)
|
59
|
-
|
66
|
+
|
67
|
+
# Create a new event if:
|
68
|
+
# 1. Status has changed OR
|
69
|
+
# 2. Status is in verify_scan_statuses AND verified flag has changed
|
70
|
+
if last_status != status
|
71
|
+
# Status changed, always create new event
|
72
|
+
service.events.create!(status:, response:, metadata: {verified:, verification: verifier.to_s})
|
73
|
+
elsif verify_scan_statuses.include?(status) && last_verified != verified
|
74
|
+
# Status same but verification result changed for a monitored status
|
75
|
+
service.events.create!(status:, response:, metadata: {verified:, verification: verifier.to_s})
|
76
|
+
end
|
60
77
|
end
|
61
78
|
end
|
62
79
|
alias_method :verify, :scan
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: close_encounters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Gay
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: railties
|
@@ -129,7 +128,6 @@ metadata:
|
|
129
128
|
homepage_uri: https://github.com/SOFware/close_encounters
|
130
129
|
source_code_uri: https://github.com/SOFware/close_encounters
|
131
130
|
changelog_uri: https://github.com/SOFware/close_encounters/blob/main/CHANGELOG.md
|
132
|
-
post_install_message:
|
133
131
|
rdoc_options: []
|
134
132
|
require_paths:
|
135
133
|
- lib
|
@@ -144,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
142
|
- !ruby/object:Gem::Version
|
145
143
|
version: '0'
|
146
144
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
145
|
+
rubygems_version: 3.6.7
|
149
146
|
specification_version: 4
|
150
147
|
summary: Close Encounters of the Third Party
|
151
148
|
test_files: []
|