This repository was archived by the owner on Nov 8, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
lib/groupher_server/cms/delegates Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -92,15 +92,7 @@ defmodule GroupherServer.CMS.Delegate.CommentCURD do
92
92
ORM . delete ( comment )
93
93
end )
94
94
|> Multi . run ( :update_floor , fn _ , _ ->
95
- Repo . update_all (
96
- from ( p in action . reactor , where: p . id > ^ comment . id ) ,
97
- inc: [ floor: - 1 ]
98
- )
99
- |> done ( )
100
- |> case do
101
- { :ok , _ } -> { :ok , comment }
102
- { :error , _ } -> { :error , "" }
103
- end
95
+ exec_update_floor ( action . reactor , comment )
104
96
end )
105
97
|> Repo . transaction ( )
106
98
|> delete_comment_result ( )
@@ -185,6 +177,18 @@ defmodule GroupherServer.CMS.Delegate.CommentCURD do
185
177
{ :error , [ message: "update follor fails" , code: ecode ( :delete_fails ) ] }
186
178
end
187
179
180
+ defp exec_update_floor ( queryable , comment ) do
181
+ Repo . update_all (
182
+ from ( p in queryable , where: p . id > ^ comment . id ) ,
183
+ inc: [ floor: - 1 ]
184
+ )
185
+ |> done ( )
186
+ |> case do
187
+ { :ok , _ } -> { :ok , comment }
188
+ { :error , _ } -> { :error , "" }
189
+ end
190
+ end
191
+
188
192
# simulate a join connection
189
193
# TODO: use Multi task to refactor
190
194
# TODO: refactor boilerplate code
You can’t perform that action at this time.
0 commit comments