rails_pulse 0.3.3.pre.2 → 0.3.3.pre.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: 70f6de9d79a6321df43145819c47aae97aeb6cf3c184c76b66aa8707eea1f80c
4
- data.tar.gz: a7c524c7a77b5f39c44eaa20a820c221d1f9e32c30baeda10d6dae78cd720ded
3
+ metadata.gz: 80612b2461699451e01b4efa5ef5143eeb6c24d042eaba019e82d1aed02145d2
4
+ data.tar.gz: 119e0dd5913f3f6930bd1fe64c4234d9196c58f2388d818a26db7c85519f350d
5
5
  SHA512:
6
- metadata.gz: 5e4486641f354374863b138553539cb9cebbcd92ee7190910af0fe5c339c459839a51b14e07cb114d90228542bc9e16a074d1404a5325ee48aa92e1557d7ea9f
7
- data.tar.gz: be64b7d1c67259124a69c20bab07fc9697f90f76ca9096f62d01a8a52663e00032833e392645c76ea4ccf0be3fa70103ab170648adcca0cf24cbd6b9c906038b
6
+ metadata.gz: 60f5e66f20e1cf0cdbeee2a1f543509a227121c758248236adc8bc1d49690f968b64335842dba4192ed0c4b960fb9cdb783b003946e60278731282d520975b5b
7
+ data.tar.gz: 9a25108617038b5ac69646fceee12a14fb9f18fc278a83f104a020ee245c74e7450111d31feb37d2357fd621e010c021ee1f77fbd74c735c24ef5ac60981faa6
@@ -60,6 +60,8 @@ module RailsPulse
60
60
 
61
61
  update!(updates)
62
62
  end
63
+ rescue ActiveRecord::RecordNotFound
64
+ RailsPulse.logger.warn "RailsPulse::Job #{id} was deleted concurrently; skipping cache update for run #{run.id}"
63
65
  end
64
66
 
65
67
  def failure_rate
@@ -13,7 +13,21 @@ module RailsPulse
13
13
  validates :path, presence: true
14
14
 
15
15
  def self.by_method_and_path(method, path)
16
- find_or_create_by!(method: method, path: path)
16
+ # Fast path: route already exists (the common case for recurring requests).
17
+ route = find_by(method: method, path: path)
18
+ return route if route
19
+
20
+ # Use INSERT ... ON CONFLICT DO NOTHING rather than create_or_find_by so that
21
+ # concurrent inserts for the same route are silently skipped at the database level.
22
+ # create_or_find_by rescues RecordNotUnique at the Ruby level, but PostgreSQL still
23
+ # logs a constraint violation ERROR before raising — causing noisy logs.
24
+ # unique_by is omitted for cross-database compatibility (MySQL rejects it); there is
25
+ # only one unique constraint on this table so DO NOTHING resolves unambiguously.
26
+ # Tags must be set explicitly here because insert bypasses before_save callbacks.
27
+ insert(
28
+ { method: method, path: path, tags: "[]", created_at: Time.current, updated_at: Time.current }
29
+ )
30
+ find_by!(method: method, path: path)
17
31
  end
18
32
 
19
33
  def self.ransackable_attributes(auth_object = nil)
@@ -26,8 +26,7 @@ module RailsPulse
26
26
  RailsPulse::ApplicationRecord.connection_pool.with_connection do
27
27
  RequestStore.store[:skip_recording_rails_pulse_activity] = true
28
28
 
29
- route = RailsPulse::Route.find_by(method: data[:method], path: data[:path]) ||
30
- RailsPulse::Route.create_or_find_by(method: data[:method], path: data[:path])
29
+ route = RailsPulse::Route.by_method_and_path(data[:method], data[:path])
31
30
 
32
31
  request = RailsPulse::Request.create!(
33
32
  route: route,
@@ -1,3 +1,3 @@
1
1
  module RailsPulse
2
- VERSION = "0.3.3.pre.2"
2
+ VERSION = "0.3.3.pre.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_pulse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3.pre.2
4
+ version: 0.3.3.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Harvey
@@ -520,7 +520,7 @@ metadata:
520
520
  changelog_uri: https://github.com/railspulse/rails_pulse/blob/main/CHANGELOG.md
521
521
  documentation_uri: https://railspulse.com/documentation/installation
522
522
  post_install_message: |
523
- Rails Pulse 0.3.3.pre.2 installed. If upgrading, run:
523
+ Rails Pulse 0.3.3.pre.3 installed. If upgrading, run:
524
524
  rails generate rails_pulse:upgrade && rails db:migrate
525
525
  rdoc_options: []
526
526
  require_paths: