@@ -5,11 +5,13 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
5
5
import ShortMaps
6
6
7
7
alias Helper . { Certification , RadarSearch , ORM }
8
- alias GroupherServer.Accounts.User
9
- alias GroupherServer.CMS.Delegate.PassportCURD
10
- alias GroupherServer.Repo
11
8
12
- alias GroupherServer.CMS . {
9
+ alias GroupherServer . { Accounts , CMS , Repo }
10
+
11
+ alias Accounts.User
12
+ alias CMS.Delegate.PassportCURD
13
+
14
+ alias CMS . {
13
15
Delegate ,
14
16
Category ,
15
17
Community ,
@@ -116,6 +118,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
116
118
|> Multi . run ( :update_community_count , fn _ , % { subscribed_community: community } ->
117
119
CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :inc )
118
120
end )
121
+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
122
+ Accounts . update_subscribe_count ( user_id )
123
+ end )
119
124
|> Repo . transaction ( )
120
125
|> result ( )
121
126
end
@@ -133,6 +138,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
133
138
|> Multi . run ( :update_community_count , fn _ , % { subscribed_community: community } ->
134
139
CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :inc )
135
140
end )
141
+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
142
+ Accounts . update_subscribe_count ( user_id )
143
+ end )
136
144
|> Repo . transaction ( )
137
145
|> result ( )
138
146
end
@@ -151,6 +159,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
151
159
|> Multi . run ( :update_community_count , fn _ , _ ->
152
160
CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
153
161
end )
162
+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
163
+ Accounts . update_subscribe_count ( user_id )
164
+ end )
154
165
|> Repo . transaction ( )
155
166
|> result ( )
156
167
else
@@ -176,6 +187,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
176
187
|> Multi . run ( :update_community_count , fn _ , _ ->
177
188
CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
178
189
end )
190
+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
191
+ Accounts . update_subscribe_count ( user_id )
192
+ end )
179
193
|> Multi . run ( :update_community_geo , fn _ , _ ->
180
194
update_community_geo ( community_id , user_id , remote_ip , :dec )
181
195
end )
@@ -204,6 +218,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
204
218
|> Multi . run ( :update_community_count , fn _ , _ ->
205
219
CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
206
220
end )
221
+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
222
+ Accounts . update_subscribe_count ( user_id )
223
+ end )
207
224
|> Multi . run ( :update_community_geo_city , fn _ , _ ->
208
225
update_community_geo_map ( community . id , city , :dec )
209
226
end )