effective_logging 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eacf844b2242cd5daa31e948a8d5b40e7fff67c9
4
- data.tar.gz: c3c9bde4856f70293a3db72c93129c652dc5cc59
3
+ metadata.gz: 764110851ffd8e9238e69e60a0dc08e1f210c6fa
4
+ data.tar.gz: 9090700d036500ba51819420446f5feeb941b0e6
5
5
  SHA512:
6
- metadata.gz: 344c156190cace9f22cf5a906718c554ff0374260682d539d4b5c5bd59a68a4a2a01f7625c9e16ac2ce380e505f0870587d9d5288c9849321ca6113fc8279208
7
- data.tar.gz: 35795a9dfce13770e69975179ed775946c1c35ae21cc2b934c284b787d53aaedb331a5181583a2a590eb9cacab25cb101aba184327a0157fa4f787a043bfcac8
6
+ metadata.gz: 270572880bdf24cca71708c5076c8920a06a186fa2c8db87c82020e1fc4f992e7cec9f2701e1bdb23152f428df053f59a66ec189a4e653fa22fc302ab9fa2df6
7
+ data.tar.gz: d6eedad46a7b9fe2bb010b28cb58d0b2738962e4d39d90e032439d01252aeff46a25189524a7247d1af0f721dac28ed5522b641c9a7c683229ca0531287b1a39
data/README.md CHANGED
@@ -321,7 +321,7 @@ If you don't want to use the builtin Admin screen, and would rather render the e
321
321
  In your controller:
322
322
 
323
323
  ```ruby
324
- @datatable = EffectiveLogsDatatable.new(self)
324
+ @datatable = EffectiveLogsDatatable.new
325
325
  ```
326
326
 
327
327
  And then in your view:
@@ -334,13 +334,11 @@ render_datatable(@datatable)
334
334
 
335
335
  We can also use a similar method to create a datatable of logs for just one user.
336
336
 
337
- When initialized with :user_id, the 'User' column is hidden and the Logs are scoped to any logs where this user is the User or Associated column.
338
-
339
- In your controller:
337
+ When initialized with :for, the logs are scoped to any log where this id matches the User or Associated column.
340
338
 
341
339
  ```ruby
342
- @user = User.find(params[:id])
343
- @datatable = EffectiveLogsDatatable.new(self, user_id: @user.id)
340
+ EffectiveLogsDatatable.new(for: @user.id)
341
+ EffectiveLogsDatatable.new(for: [1, 2, 3]) # Users with ID 1, 2 and 3
344
342
  ```
345
343
 
346
344
 
@@ -8,10 +8,8 @@ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
8
8
 
9
9
  if attributes[:user] == false
10
10
  # Do not include
11
- elsif attributes[:user_id].present?
12
- col :user, search: { collection: User.where(id: Array(attributes[:user_id])) }
13
- elsif attributes[:user].present?
14
- col :user, search: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
11
+ elsif attributes[:for]
12
+ col :user, search: :string
15
13
  else
16
14
  col :user
17
15
  end
@@ -54,8 +52,8 @@ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
54
52
  scope = scope.where(status: EffectiveLogging.log_changes_status)
55
53
  end
56
54
 
57
- if (attributes[:user] || attributes[:user_id]).present?
58
- user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
55
+ if attributes[:for]
56
+ user_ids = Array(attributes[:for])
59
57
  scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
60
58
  end
61
59
 
@@ -21,8 +21,11 @@ module EffectiveLogging
21
21
  logged_fields[:email] = "#{message.header}<hr>#{(body.presence || message.body)}"
22
22
 
23
23
  (message.to || []).each do |to|
24
+ user = (User.where(email: to).first rescue nil)
25
+
24
26
  logged_fields[:to] = to
25
- logged_fields[:associated] ||= (User.where(email: to).first rescue nil)
27
+ logged_fields[:associated] ||= user
28
+ logged_fields[:user] ||= user
26
29
 
27
30
  ::EffectiveLogger.email("#{message.subject} - #{message.to.join(', ')}", logged_fields)
28
31
  end
@@ -34,7 +34,7 @@ module EffectiveLogging
34
34
  end
35
35
  end
36
36
 
37
- # # Register the log_page_views concern so that it can be called in ActionController or elsewhere
37
+ # Register the log_page_views concern so that it can be called in ActionController or elsewhere
38
38
  initializer 'effective_logging.log_changes_action_controller' do |app|
39
39
  Rails.application.config.to_prepare do
40
40
  ActiveSupport.on_load :action_controller do
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.11.0'.freeze
2
+ VERSION = '1.11.1'.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: 1.11.0
4
+ version: 1.11.1
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: 2017-08-18 00:00:00.000000000 Z
11
+ date: 2017-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails