close_encounters 0.2.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5a45c4e3e354b03b9079a8877bb298d552856412fb402378ea5070f2e904253
4
- data.tar.gz: 11cc60f66488168126254be369d7a34e0a162d01c644c9f56f942685d232bb46
3
+ metadata.gz: 67adeb4fe53671ebcc9e37f040245dd7650ec3afc83433e13415c290617ee356
4
+ data.tar.gz: e7afee308898aa7a25cf3ddfaa652369c74fdb074c014054ee37438babe0b714
5
5
  SHA512:
6
- metadata.gz: a560de8306f8e738f72fab9b070c2977301d07b4aa1e9b81ef959dbcc669d70a088f58af1fea9f640a8893ca559167758ab55ca2b8cab3cbaf2cf726d51180bd
7
- data.tar.gz: 4e54a853db68694c94cbe3c339449ed460f6692a99df3c86a2aa11194bfd9520a0d29cf8f197e158202ff017132f2cf3de8c6a6483eed2b867976188bb3d880c
6
+ metadata.gz: e0131dcd0a979e6bf3583fe3b90c91b597defbf0f660b8bfaaf2f8d2988a3b1714177148a6cec10078f1a69b8175de7c27d6bccc29523001264ca8c6f667e381
7
+ data.tar.gz: 117c8347983b35986897f55920c4d8472be867598901ca2e83bbf51f2560f083e8c6b9e27559f67c327faa66cbde30b93c1cdb19abd1e9356e792411992ff385
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ 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.3] - 2025-09-08
9
+
10
+ ### Fixed
11
+
12
+ - Fix duplicate event creation in `scan` method when status and verification state are unchanged
13
+
8
14
  ## [0.2.2] - 2025-09-04
9
15
 
10
16
  ### Changed
@@ -14,14 +20,3 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
14
20
  ### Fixed
15
21
 
16
22
  - Ensure that status is an integer when creating events and comparing results.
17
-
18
- ## [0.2.1] - 2025-03-05
19
-
20
- ### Added
21
-
22
- - Add alias for verify method as scan.
23
- - Add configuration for auto_contact and verify_scan_statuses.
24
-
25
- ### Changed
26
-
27
- - 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.
@@ -1,3 +1,3 @@
1
1
  module CloseEncounters
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -57,12 +57,22 @@ module CloseEncounters
57
57
  status = status.to_i # Ensure status is always an integer
58
58
 
59
59
  service.with_lock do
60
- if service.events.newest.pick(:status) != status
61
- verified = verifier.call(response)
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
65
+ verified = verifier.call(response)
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
62
75
  service.events.create!(status:, response:, metadata: {verified:, verification: verifier.to_s})
63
- elsif verify_scan_statuses.include?(status)
64
- verified = verifier.call(response)
65
- service.events.create!(status:, response:, metadata: {verified:, verification: verifier.to_s}) if !verified
66
76
  end
67
77
  end
68
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: close_encounters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay