wfl_simple_activity 0.1.8 → 0.1.13

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: 78c695fff52b625303bdd26c47fc3ca061a2bdf11e804f19f18df10e9f6226fb
4
- data.tar.gz: ebfab69067ca298b6db7cddf5a637b66c43f3a2da7946715ad6612352b45dd65
3
+ metadata.gz: c141b35fb1b361c462e67dc5379ef1f83db47d6355ca1b59e7c433b62debf147
4
+ data.tar.gz: 64f29ebc950729d31182119894c800e3a69a1067f66614773203fad039ab5c48
5
5
  SHA512:
6
- metadata.gz: c41f3ae3f24c6bd099b49b26523f93e02174581b5d8f5c816925d7f8c613c9efba9ff36ec2062f3bcc356bf61784116dcacd1519b8968ea982375488230b754b
7
- data.tar.gz: edd719a3310ed9bedc1d521b2ccc3ba8dbc84c37eb53b08a288b4ef54a33c8c00c6779f9cf8a2879cc1f80fde0bf34cf4d6bd758ea9fee9d98fb5c7c5a2e7d23
6
+ metadata.gz: '0317108daeabb9009e9d06751f34cd96c808b3968426a1287286f0ab5804f9764135d1aa19a6163ddc00a93dbe65a8936d673547ac8db493f34bb7cb54574c20'
7
+ data.tar.gz: aef30148b5457d759bc0125d07bb0279dd4cb105b341cd70fbd636e1e69fad60600f4db6a6fea68a3f42a1701676c86338be8f0cf9b280032d4be359e57029a6
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
data/README.md CHANGED
@@ -1,10 +1,8 @@
1
1
  # WflSimpleActivity
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/wfl_simple_activity`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ 一个用以记录用户数据操作日志的Gem
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
5
+ ## 安装
8
6
 
9
7
  Add this line to your application's Gemfile:
10
8
 
@@ -20,16 +18,19 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install wfl_simple_activity
22
20
 
23
- ## Usage
21
+ ## 用法
24
22
 
25
23
  $ rails g wfl_simple_activity:install
26
24
  $ rake db:migrate
27
25
 
28
- ## Development
26
+ ## 开发
29
27
 
30
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+ #### 单表记录
29
+ * 执行上面两步之后,在需要记录数据变更的Model中 `include CommonActivity` ,这样便会记录该Model的数据变更日志,在
30
+ 数据发生变化,将会创建 `activity`, 在项目中可以通过 `model_name.activities` 或者 `PublicActivity::Activity.where(condition)`来获取活动日志
31
31
 
32
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+ #### 关联表记录 或者 其余特殊情况
33
+ * 如果需要在关联模型数据发生变更时记录当前模型的`activity`,需要自行在关联的模型中通过`model_name.create_activity key: 'article.commented_on', owner: current_user, recipient: recipientm`来创建`activity`,create_activity方法参数可参考 [PublicActivity::Common#create_activity](https://rubydoc.info/gems/public_activity/PublicActivity/Common:create_activity)
33
34
 
34
35
  ## Contributing
35
36
 
@@ -20,7 +20,7 @@ module WflSimpleActivity
20
20
  end
21
21
 
22
22
  def copy_common_activity
23
- copy_file "common_activity.rb", "app/models/common_activity.rb"
23
+ copy_file "wfl_activity.rb", "app/models/concerns/wfl_activity.rb"
24
24
  end
25
25
 
26
26
  def copy_activity_model
@@ -1,4 +1,4 @@
1
- module CommonActivity
1
+ module WflActivity
2
2
  extend ActiveSupport::Concern
3
3
  included do |base|
4
4
  include PublicActivity::Model
@@ -10,5 +10,12 @@ module CommonActivity
10
10
  request_params: proc {|controller, model| controller&.params&.to_h}
11
11
  }
12
12
  )
13
+
14
+ # 如果不需要删除记录
15
+ # has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
16
+
17
+ after_rollback proc {
18
+ self.create_activity key: "#{self.class.name.underscore}.failed", owner: User.find(Thread.current[:user_id]), recipient: self
19
+ }
13
20
  end
14
21
  end
@@ -11,5 +11,13 @@ module CommonActivity
11
11
  request_params: proc {|controller, model| controller&.params&.to_h}
12
12
  }
13
13
  )
14
+
15
+ has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
16
+
17
+ after_rollback proc {
18
+ self.create_activity key: "#{self.class.name.underscore}.failed", recipient: self
19
+ # 由于这里无法获取controller,需要自行采用其他方式来获取current_user,比如: 在oa-saas中有个Thread.current保存了全局的变量
20
+ # self.create_activity key: "#{self.class.name.underscore}.failed", owner: User.find(Thread.current[:user_id]), recipient: self
21
+ }
14
22
  end
15
23
  end
@@ -1,3 +1,3 @@
1
1
  module WflSimpleActivity
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wfl_simple_activity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - longhaoran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-10 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: public_activity
@@ -67,19 +67,11 @@ files:
67
67
  - bin/setup
68
68
  - lib/generators/wfl_simple_activity/install_generator.rb
69
69
  - lib/generators/wfl_simple_activity/templates/activity.rb
70
- - lib/generators/wfl_simple_activity/templates/common_activity.rb
71
70
  - lib/generators/wfl_simple_activity/templates/create_activities.rb
71
+ - lib/generators/wfl_simple_activity/templates/wfl_activity.rb
72
72
  - lib/wfl_simple_activity.rb
73
73
  - lib/wfl_simple_activity/common_activity.rb
74
74
  - lib/wfl_simple_activity/version.rb
75
- - wfl_simple_activity-0.1.0.gem
76
- - wfl_simple_activity-0.1.1.gem
77
- - wfl_simple_activity-0.1.2.gem
78
- - wfl_simple_activity-0.1.3.gem
79
- - wfl_simple_activity-0.1.4.gem
80
- - wfl_simple_activity-0.1.5.gem
81
- - wfl_simple_activity-0.1.6.gem
82
- - wfl_simple_activity-0.1.7.gem
83
75
  - wfl_simple_activity.gemspec
84
76
  homepage: https://github.com/LongLonghaoran/wfl_simple_activity
85
77
  licenses: []