action-store 0.3.0 → 0.3.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: 26301184cdf3a950440f0d0c565943abdc8db2ef
4
- data.tar.gz: df943444fc2af10a16eb54a76ea0174035f05258
3
+ metadata.gz: de37a7be16b770b8b6b8b8ca44798a6b1d9941e6
4
+ data.tar.gz: c50aa313cb842917ffaa4e74069b071b9ddd9a07
5
5
  SHA512:
6
- metadata.gz: 3cde2d271a90c35adbf0bb7ec046536e2e2c86349ef71e3d647e46b4c0a16d644eb37e168fb16e1ce488e1e7e78053da05ca5f01e1896b4a0fb1ebabe1b56d25
7
- data.tar.gz: ec5998dff944bac6dbd5ebba2717e902eff60dd760013e34ab062f23840d5f3cd8c342880e52b9e445abd9fda0fd55980084fae63c9bc2351cbb8ba48c2490fc
6
+ metadata.gz: d72b82f17bac184f5b5b15be3a1de23afcfc2e500ea1051a4b40184de10b84bdc89aedd64f5919c211806dab8ab6308fc7536fd3d6b7593a1e94712b5d8dfd9e
7
+ data.tar.gz: cc8e5df4702bfd78c36be9ec64b4619a6ac3fcf430053a3044bc0cf349c485466d4df58bd68117aeb7f51347168211f3765efd4f19a580f1c9709366555cd580
@@ -1,3 +1,8 @@
1
+ 0.3.1
2
+ -----
3
+
4
+ - Fix that `:user_counter_cache` was incorrect, it not count with target_type.
5
+
1
6
  0.3.0
2
7
  -----
3
8
 
data/README.md CHANGED
@@ -56,7 +56,7 @@ end
56
56
  #### Convention Over Configuration:
57
57
 
58
58
  | action, target | Target Model | Target `counter_cache_field` | User `counter_cache_field` | Target has_many | User has_many |
59
- | ------ | ------ | ------ | ------ | ------ | ------ | ------ |
59
+ |----------------|--------------|------------------------------|----------------------------|-----------------|---------------|
60
60
  | `action_store :like, :post` | `Post` | | | `has_many :like_by_user_actions`, `has_many :like_by_users` | `has_many :like_post_actions`, `has_many :like_posts` |
61
61
  | `action_store :like, :post, counter_cache: true` | `Post` | `likes_count` | | `has_many :like_by_user_actions`, `has_many :like_by_users` | `has_many :like_post_actions`, `has_many :like_posts` |
62
62
  | `action_store :star, :project, class_name: 'Repository'` | `Repository ` | `stars_count` | `star_projects_count` | `has_many :star_by_user_actions`, `has_many :star_by_users` |
@@ -108,11 +108,18 @@ module ActionStore
108
108
  def reset_counter_cache(action, defined_action)
109
109
  return false if action.blank?
110
110
  if defined_action[:counter_cache] && action.target.present?
111
- target_count = Action.where({ action_type: defined_action[:action_type], target: action.target }).count
111
+ target_count = Action.where(
112
+ action_type: defined_action[:action_type],
113
+ target: action.target
114
+ ).count
112
115
  action.target.update_attribute(defined_action[:counter_cache], target_count)
113
116
  end
114
117
  if defined_action[:user_counter_cache] && action.user.present?
115
- user_count = Action.where({ action_type: defined_action[:action_type], user: action.user }).count
118
+ user_count = Action.where(
119
+ action_type: defined_action[:action_type],
120
+ target_type: action.target_type,
121
+ user: action.user
122
+ ).count
116
123
  action.user.update_attribute(defined_action[:user_counter_cache], user_count)
117
124
  end
118
125
  end
@@ -1,3 +1,3 @@
1
1
  module ActionStore
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action-store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.6.8
74
+ rubygems_version: 2.6.11
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Store difference kind of actions (Like, Follow, Star, Block ...) in one table.