acts_as_trackable 0.4.1 → 0.4.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: 69a6aa75568eb589a8c65044e6ea53fb3acf026554bd81515767b1a41ff8817f
4
- data.tar.gz: e2dc8735530dbb20a63c21d5fd714f3cb8fe8b7895908804294db9ac8675f197
3
+ metadata.gz: fe57cd1a0aa59befd8065f81bc9a7800072c6779775ce3e0f03205128bb09c0b
4
+ data.tar.gz: 339d18abf2766051d60d2bddba1939b2d6b0fa5ffd07d249508ded87f12224ef
5
5
  SHA512:
6
- metadata.gz: 63a6c3ed2c204153d4d14dbf60cffd5183dfb18d3aae4afd78deb7a42d9c127d5d9e2f10a7113897ea6ad89290a5f80078132f86daba6eb2c2619e38dc8004d2
7
- data.tar.gz: 2c2914f5a6e1146dbe602a5ef25ab611d1415790aeb4bb3b9f24b7d9c9d9e6e44b4ced964402856ce1e558ac2ccbe2e3cae0685bc4bcc203bbb3ca3aa84c9eb3
6
+ metadata.gz: 3fa0b497529b74d0cc9a328c777dea23c2b7b946e8c9a18d6b3d93d83cd2d4d678783f295b3cd622e8a0366445a16fdfe5889e81159cc25a45ad85b918ba3938
7
+ data.tar.gz: 4d83c9daeafa0944bb92fcde1b014bdeff9cff1e898f074f6594901dd8880144dd50ea1cca803779013b8471b47c874562e0c38174507eaec1bd8059dbe904db
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- acts_as_trackable (0.4.1)
4
+ acts_as_trackable (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (7.2.2.1)
10
- actionview (= 7.2.2.1)
11
- activesupport (= 7.2.2.1)
9
+ actionpack (7.2.2.2)
10
+ actionview (= 7.2.2.2)
11
+ activesupport (= 7.2.2.2)
12
12
  nokogiri (>= 1.8.5)
13
13
  racc
14
14
  rack (>= 2.2.4, < 3.2)
@@ -17,19 +17,19 @@ GEM
17
17
  rails-dom-testing (~> 2.2)
18
18
  rails-html-sanitizer (~> 1.6)
19
19
  useragent (~> 0.16)
20
- actionview (7.2.2.1)
21
- activesupport (= 7.2.2.1)
20
+ actionview (7.2.2.2)
21
+ activesupport (= 7.2.2.2)
22
22
  builder (~> 3.1)
23
23
  erubi (~> 1.11)
24
24
  rails-dom-testing (~> 2.2)
25
25
  rails-html-sanitizer (~> 1.6)
26
- activemodel (7.2.2.1)
27
- activesupport (= 7.2.2.1)
28
- activerecord (7.2.2.1)
29
- activemodel (= 7.2.2.1)
30
- activesupport (= 7.2.2.1)
26
+ activemodel (7.2.2.2)
27
+ activesupport (= 7.2.2.2)
28
+ activerecord (7.2.2.2)
29
+ activemodel (= 7.2.2.2)
30
+ activesupport (= 7.2.2.2)
31
31
  timeout (>= 0.4.0)
32
- activesupport (7.2.2.1)
32
+ activesupport (7.2.2.2)
33
33
  base64
34
34
  benchmark (>= 0.3)
35
35
  bigdecimal
@@ -41,15 +41,15 @@ GEM
41
41
  minitest (>= 5.1)
42
42
  securerandom (>= 0.3)
43
43
  tzinfo (~> 2.0, >= 2.0.5)
44
- base64 (0.2.0)
45
- benchmark (0.4.0)
46
- bigdecimal (3.1.9)
44
+ base64 (0.3.0)
45
+ benchmark (0.4.1)
46
+ bigdecimal (3.2.2)
47
47
  builder (3.3.0)
48
48
  concurrent-ruby (1.3.5)
49
- connection_pool (2.5.0)
49
+ connection_pool (2.5.3)
50
50
  crass (1.0.6)
51
51
  date (3.4.1)
52
- drb (2.2.1)
52
+ drb (2.2.3)
53
53
  erubi (1.13.1)
54
54
  generator_spec (0.10.0)
55
55
  activesupport (>= 3.0.0)
@@ -61,7 +61,7 @@ GEM
61
61
  pp (>= 0.6.0)
62
62
  rdoc (>= 4.0.0)
63
63
  reline (>= 0.4.2)
64
- logger (1.6.6)
64
+ logger (1.7.0)
65
65
  loofah (2.24.0)
66
66
  crass (~> 1.0.2)
67
67
  nokogiri (>= 1.12.0)
@@ -92,9 +92,9 @@ GEM
92
92
  rails-html-sanitizer (1.6.2)
93
93
  loofah (~> 2.21)
94
94
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
95
- railties (7.2.2.1)
96
- actionpack (= 7.2.2.1)
97
- activesupport (= 7.2.2.1)
95
+ railties (7.2.2.2)
96
+ actionpack (= 7.2.2.2)
97
+ activesupport (= 7.2.2.2)
98
98
  irb (~> 1.13)
99
99
  rackup (>= 1.0.0)
100
100
  rake (>= 12.2)
data/changelog.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # acts_as_trackable Changelog
2
- ## Version: 0.4.0
2
+ ## Version: 0.4.3
3
+ ### Patch
4
+ - Performance Fix: Fixed N+1 query issue when accessing `created_by` and `updated_by` after eager loading.
5
+
6
+ - The `created_by` and `updated_by` methods now properly respect preloaded associations.
7
+ - When using `includes(object_activity: [:created_by, :updated_by])` or `Preloader.new(records: records, associations: { object_activity: %i[created_by updated_by] })`, the methods now use the preloaded data instead of triggering additional database queries.
8
+
9
+ - Added comprehensive test coverage for N+1 query prevention scenarios.
10
+ - Migration Note: This is a non-breaking change. Existing code will continue to work, but performance will improve when using nested eager loading.
11
+ ## Version: 0.4.2
12
+ ### Patch
13
+ - Upgraded dependencies to patch CVE-2025-55193.
14
+ ## Version: 0.4.1
3
15
  ### Patch
4
16
  - Upgraded dependencies to patch CVE-2025-6021, CVE-2025-6170, CVE-2025-49794, CVE-2025-49795, CVE-2025-49796, and CVE-2025-54314.
5
17
  ## Version: 0.4.0
@@ -29,8 +29,37 @@ module Trackable
29
29
  )
30
30
  end
31
31
 
32
+ # Custom created_by method that respects preloading
33
+ define_method :created_by do
34
+ return nil unless object_activity
32
35
 
33
- delegate :created_by, :updated_by, to: :object_activity, allow_nil: true
36
+ # Return cached value if already set
37
+ return @created_by if defined?(@created_by)
38
+
39
+ # Check if created_by is preloaded on the object_activity
40
+ if object_activity.association(:created_by).loaded?
41
+ @created_by = object_activity.association(:created_by).target
42
+ else
43
+ # Fallback to default association behavior
44
+ @created_by = object_activity.created_by
45
+ end
46
+ end
47
+
48
+ # Custom updated_by method that respects preloading
49
+ define_method :updated_by do
50
+ return nil unless object_activity
51
+
52
+ # Return cached value if already set
53
+ return @updated_by if defined?(@updated_by)
54
+
55
+ # Check if updated_by is preloaded on the object_activity
56
+ if object_activity.association(:updated_by).loaded?
57
+ @updated_by = object_activity.association(:updated_by).target
58
+ else
59
+ # Fallback to default association behavior
60
+ @updated_by = object_activity.updated_by
61
+ end
62
+ end
34
63
 
35
64
  after_commit :log_object_activity, on: %i[create update], if: -> { modifier.present? }
36
65
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsTrackable
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_trackable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmad Keewan
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-07-28 00:00:00.000000000 Z
12
+ date: 2025-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: generator_spec