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
9292 ORM . delete ( comment )
9393 end )
9494 |> 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 )
10496 end )
10597 |> Repo . transaction ( )
10698 |> delete_comment_result ( )
@@ -185,6 +177,18 @@ defmodule GroupherServer.CMS.Delegate.CommentCURD do
185177 { :error , [ message: "update follor fails" , code: ecode ( :delete_fails ) ] }
186178 end
187179
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+
188192 # simulate a join connection
189193 # TODO: use Multi task to refactor
190194 # TODO: refactor boilerplate code
You can’t perform that action at this time.
0 commit comments