effective_logging 4.1.2 → 4.1.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: 7e070e874fc63fecb6464d0c4648cc15e09e88fbcc7a30110654070dfcfadac9
4
- data.tar.gz: e0cca60b349ad639ecbc98eb7f51262baa266e23fa79c6c05250db55d38c1ea3
3
+ metadata.gz: a7f4fc3d49401f3b6662c151df50c0950d3a6679fcb8e5e8a157faa6e442f8ae
4
+ data.tar.gz: b650b9465adbaeae418d3d9860ec5a83fa3bd16cc465127322d56de4e15f3bb5
5
5
  SHA512:
6
- metadata.gz: 94ed4840cca24c47b64024f652ec7e2374fee2d2b83c393b801e623b92472c903e93aa743f8573dbe7677c615d5e393a614080602c5900738b587eb9535c6654
7
- data.tar.gz: 063274f9e2bff0309335b557ca3777aa8612cc03ac8860a8b9a8dc15535ddaa89b43535a9f0687d3f53f534a92071c42ce72ca23861809381b4dca90e6e93003
6
+ metadata.gz: 6eb6deb9117fc08a647a68e0a2c76d7de045e2a3fd2b297f69eb94dac549b1d93d9457723261772f7ca426dabcbd62d9b002265d31f8442487e196970957d5b3
7
+ data.tar.gz: 4f70acc13305458ec9a8154c1bb3846834660de3ee3bab3a3280264aaa83b83973615b01fcb16c372aadc7b6ee33e5e69af8543efc65e8d63b35fa5c78904ca1
data/README.md CHANGED
@@ -318,8 +318,7 @@ We can also use a similar method to create a datatable of logs for just one user
318
318
  When initialized with :for, the logs are scoped to any log where this id matches the User or Associated column.
319
319
 
320
320
  ```ruby
321
- EffectiveLogsDatatable.new(for: @user.id)
322
- EffectiveLogsDatatable.new(for: [1, 2, 3]) # Users with ID 1, 2 and 3
321
+ EffectiveLogsDatatable.new(for: @user)
323
322
  ```
324
323
 
325
324
  ### Upgrade from 2.0
@@ -43,7 +43,7 @@ module Effective
43
43
  # This is the User index event
44
44
  def index
45
45
  EffectiveResources.authorize!(self, :index, resource_scope.new(user: current_user, user_id: current_user.id))
46
- @datatable = EffectiveLogsDatatable.new(self, for: current_user.id)
46
+ @datatable = EffectiveLogsDatatable.new(self, for: current_user)
47
47
  end
48
48
 
49
49
  def html_part
@@ -44,24 +44,19 @@ class EffectiveLogsDatatable < Effective::Datatable
44
44
  collection do
45
45
  scope = EffectiveLogging.Log.deep.all
46
46
 
47
- # Older syntax, pass by integer
48
- if attributes[:for]
49
- user_ids = Array(attributes[:for])
50
- scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
51
- end
52
-
53
47
  # Newer syntax, pass by object
54
48
  if attributes[:for_id] && attributes[:for_type]
55
49
  scope = scope.where(associated_id: attributes[:for_id], associated_type: attributes[:for_type])
56
50
  .or(scope.where(changes_to_id: attributes[:for_id], changes_to_type: attributes[:for_type]))
57
51
  .or(scope.where(user_id: attributes[:for_id], user_type: attributes[:for_type]))
52
+ elsif attributes[:for] # Older syntax, pass by integer
53
+ user_ids = Array(attributes[:for])
54
+ scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
58
55
  end
59
56
 
60
57
  if attributes[:associated_id] && attributes[:associated_type]
61
58
  scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
62
- end
63
-
64
- if attributes[:associated]
59
+ elsif attributes[:associated]
65
60
  scope = scope.where(associated: attributes[:associated])
66
61
  end
67
62
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '4.1.2'.freeze
2
+ VERSION = '4.1.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2024-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails