@@ -68,17 +68,17 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
6868 { :ok , action } <- match_action ( thread , :community ) ,
6969 { :ok , community } <- ORM . find ( Community , community_id ) do
7070 Multi . new ( )
71- |> Multi . run ( :add_content_author , fn _ ->
71+ |> Multi . run ( :add_content_author , fn _ , _ ->
7272 action . target
7373 |> struct ( )
7474 |> action . target . changeset ( attrs )
7575 |> Ecto.Changeset . put_change ( :author_id , author . id )
7676 |> Repo . insert ( )
7777 end )
78- |> Multi . run ( :set_community , fn % { add_content_author: content } ->
78+ |> Multi . run ( :set_community , fn _ , % { add_content_author: content } ->
7979 ArticleOperation . set_community ( community , thread , content . id )
8080 end )
81- |> Multi . run ( :set_topic , fn % { add_content_author: content } ->
81+ |> Multi . run ( :set_topic , fn _ , % { add_content_author: content } ->
8282 topic_title =
8383 case attrs |> Map . has_key? ( :topic ) do
8484 true -> attrs . topic
@@ -87,7 +87,7 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
8787
8888 ArticleOperation . set_topic ( % Topic { title: topic_title } , thread , content . id )
8989 end )
90- |> Multi . run ( :set_community_flag , fn % { add_content_author: content } ->
90+ |> Multi . run ( :set_community_flag , fn _ , % { add_content_author: content } ->
9191 # TODO: remove this judge, as content should have a flag
9292 case action |> Map . has_key? ( :flag ) do
9393 true ->
@@ -99,17 +99,17 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
9999 { :ok , "pass" }
100100 end
101101 end )
102- |> Multi . run ( :set_tag , fn % { add_content_author: content } ->
102+ |> Multi . run ( :set_tag , fn _ , % { add_content_author: content } ->
103103 case attrs |> Map . has_key? ( :tags ) do
104104 true -> set_tags ( community , thread , content . id , attrs . tags )
105105 false -> { :ok , "pass" }
106106 end
107107 end )
108- |> Multi . run ( :mention_users , fn % { add_content_author: content } ->
108+ |> Multi . run ( :mention_users , fn _ , % { add_content_author: content } ->
109109 Delivery . mention_from_content ( thread , content , attrs , % User { id: user_id } )
110110 { :ok , "pass" }
111111 end )
112- |> Multi . run ( :log_action , fn _ ->
112+ |> Multi . run ( :log_action , fn _ , _ ->
113113 Statistics . log_publish_action ( % User { id: user_id } )
114114 end )
115115 |> Repo . transaction ( )
@@ -132,7 +132,7 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
132132 { :error , [ message: "set community flag" , code: ecode ( :create_fails ) ] }
133133 end
134134
135- defp create_content_result ( { :error , :set_topic , result , _steps } ) do
135+ defp create_content_result ( { :error , :set_topic , _result , _steps } ) do
136136 { :error , [ message: "set topic" , code: ecode ( :create_fails ) ] }
137137 end
138138
@@ -227,7 +227,7 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
227227 |> join ( :inner , [ p ] , content in assoc ( p , :post ) )
228228 |> where (
229229 [ p , c , t , content ] ,
230- c . raw == ^ filter . community and t . raw == ^ Map . get ( filter , :topic , "posts" )
230+ c . raw == ^ community and t . raw == ^ Map . get ( filter , :topic , "posts" )
231231 )
232232 |> select ( [ p , c , t , content ] , content )
233233 # 10 pined contents per community/thread, at most
@@ -241,19 +241,21 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
241241 end
242242 end
243243
244- defp add_pin_contents_ifneed ( contents , CMS.Job , % { community: community } = filter ) do
244+ defp add_pin_contents_ifneed ( contents , CMS.Job , % { community: _community } = filter ) do
245245 merge_pin_contents ( contents , :job , CMS.PinedJob , filter )
246246 end
247247
248- defp add_pin_contents_ifneed ( contents , CMS.Video , % { community: community } = filter ) do
248+ defp add_pin_contents_ifneed ( contents , CMS.Video , % { community: _community } = filter ) do
249249 merge_pin_contents ( contents , :video , CMS.PinedVideo , filter )
250250 end
251251
252- defp add_pin_contents_ifneed ( contents , CMS.Repo , % { community: community } = filter ) do
252+ defp add_pin_contents_ifneed ( contents , CMS.Repo , % { community: _community } = filter ) do
253253 merge_pin_contents ( contents , :repo , CMS.PinedRepo , filter )
254254 end
255255
256- defp merge_pin_contents ( contents , thread , pin_schema , % { community: community } = filter ) do
256+ defp add_pin_contents_ifneed ( contents , _querable , _filter ) , do: contents
257+
258+ defp merge_pin_contents ( contents , thread , pin_schema , % { community: _community } = filter ) do
257259 with { :ok , normal_contents } <- contents ,
258260 true <- Map . has_key? ( filter , :community ) ,
259261 true <- 1 == Map . get ( normal_contents , :page_number ) do
@@ -274,8 +276,6 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
274276 end
275277 end
276278
277- defp add_pin_contents_ifneed ( contents , _querable , _filter ) , do: contents
278-
279279 defp concat_contents ( pined_content , normal_contents ) do
280280 case pined_content |> Map . get ( :total_count ) do
281281 0 ->
0 commit comments