wfl_simple_activity 0.1.9 → 0.1.10

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: fb07938e75e645aa72551e8626b37338fc2e9f5a1b0201c941246d53390aee43
4
- data.tar.gz: 907f485b24a088d0e76c3e8ada74cffc1e6ff5065f9508ea4c59350f3b8d5625
3
+ metadata.gz: ef40e75630951d16587c80eea6834427dc73c847b5fa2fa92937e0ca81435d47
4
+ data.tar.gz: 3cf0e655f947ffac3ee0ace75b5d4607f498f068c5c9dff3dbf81c1eae691602
5
5
  SHA512:
6
- metadata.gz: 056fbcc244291f2c74335ea5f52b052bcca3af940a0d9912c265a65e81a0ac89b35c35d7889e337dbb321a0720af54813941c68cb0e6402e1f98d67b927bed9a
7
- data.tar.gz: 52f1cf876b6926c0aeb6d9c92cbbed65eaf7daa596b982e67216d75ed3ff562d165f9221f0c34b4a1f42e0bb6475b00d5d3f0967d467bc3135b004e661cd33dd
6
+ metadata.gz: 87212bd407e9cced000ecd36ed280e872242806c43f29fb26694fdb1d591fea02666e08bfd184706141521ebc721ea553a83b153d3399e2290f406205661583c
7
+ data.tar.gz: 969b48f4f19de675349a582d516b19c28830a25391ef261ad46cb571499a44cb0c4352f947a7474f7f0bd85a8fe4b6745942bde81f4c1f95a21d0107bd0617e1
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
 
@@ -10,5 +10,11 @@ module CommonActivity
10
10
  request_params: proc {|controller, model| controller&.params&.to_h}
11
11
  }
12
12
  )
13
+
14
+ has_many :activities, as: :trackable, class_name: 'PublicActivity::Activity', dependent: :destroy
15
+
16
+ after_rollback proc {
17
+ self.create_activity key: "#{self.class.name.underscore}.failed", owner: User.find(Thread.current[:user_id]), recipient: self
18
+ }
13
19
  end
14
20
  end
@@ -1,3 +1,3 @@
1
1
  module WflSimpleActivity
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
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.9
4
+ version: 0.1.10
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-11 00:00:00.000000000 Z
11
+ date: 2019-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: public_activity