@@ -5,11 +5,13 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
55 import ShortMaps
66
77 alias Helper . { Certification , RadarSearch , ORM }
8- alias GroupherServer.Accounts.User
9- alias GroupherServer.CMS.Delegate.PassportCURD
10- alias GroupherServer.Repo
118
12- alias GroupherServer.CMS . {
9+ alias GroupherServer . { Accounts , CMS , Repo }
10+
11+ alias Accounts.User
12+ alias CMS.Delegate.PassportCURD
13+
14+ alias CMS . {
1315 Delegate ,
1416 Category ,
1517 Community ,
@@ -116,6 +118,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
116118 |> Multi . run ( :update_community_count , fn _ , % { subscribed_community: community } ->
117119 CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :inc )
118120 end )
121+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
122+ Accounts . update_subscribe_count ( user_id )
123+ end )
119124 |> Repo . transaction ( )
120125 |> result ( )
121126 end
@@ -133,6 +138,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
133138 |> Multi . run ( :update_community_count , fn _ , % { subscribed_community: community } ->
134139 CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :inc )
135140 end )
141+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
142+ Accounts . update_subscribe_count ( user_id )
143+ end )
136144 |> Repo . transaction ( )
137145 |> result ( )
138146 end
@@ -151,6 +159,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
151159 |> Multi . run ( :update_community_count , fn _ , _ ->
152160 CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
153161 end )
162+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
163+ Accounts . update_subscribe_count ( user_id )
164+ end )
154165 |> Repo . transaction ( )
155166 |> result ( )
156167 else
@@ -176,6 +187,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
176187 |> Multi . run ( :update_community_count , fn _ , _ ->
177188 CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
178189 end )
190+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
191+ Accounts . update_subscribe_count ( user_id )
192+ end )
179193 |> Multi . run ( :update_community_geo , fn _ , _ ->
180194 update_community_geo ( community_id , user_id , remote_ip , :dec )
181195 end )
@@ -204,6 +218,9 @@ defmodule GroupherServer.CMS.Delegate.CommunityOperation do
204218 |> Multi . run ( :update_community_count , fn _ , _ ->
205219 CommunityCURD . update_community_count_field ( community , user_id , :subscribers_count , :dec )
206220 end )
221+ |> Multi . run ( :update_user_subscribe_count , fn _ , _ ->
222+ Accounts . update_subscribe_count ( user_id )
223+ end )
207224 |> Multi . run ( :update_community_geo_city , fn _ , _ ->
208225 update_community_geo_map ( community . id , city , :dec )
209226 end )
0 commit comments