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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/action_store/mixin.rb +9 -2
- data/lib/action_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de37a7be16b770b8b6b8b8ca44798a6b1d9941e6
|
4
|
+
data.tar.gz: c50aa313cb842917ffaa4e74069b071b9ddd9a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d72b82f17bac184f5b5b15be3a1de23afcfc2e500ea1051a4b40184de10b84bdc89aedd64f5919c211806dab8ab6308fc7536fd3d6b7593a1e94712b5d8dfd9e
|
7
|
+
data.tar.gz: cc8e5df4702bfd78c36be9ec64b4619a6ac3fcf430053a3044bc0cf349c485466d4df58bd68117aeb7f51347168211f3765efd4f19a580f1c9709366555cd580
|
data/CHANGELOG.md
CHANGED
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` |
|
data/lib/action_store/mixin.rb
CHANGED
@@ -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(
|
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(
|
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
|
data/lib/action_store/version.rb
CHANGED
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.
|
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.
|
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.
|