@@ -3,7 +3,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
33 CURD and operations for article comments
44 """
55 import Ecto.Query , warn: false
6- import Helper.Utils , only: [ done: 1 , get_config: 2 ]
6+ import Helper.Utils , only: [ done: 1 ]
77 import Helper.ErrorCode
88
99 import GroupherServer.CMS.Delegate.Helper , only: [ mark_viewer_emotion_states: 3 ]
@@ -15,16 +15,15 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
1515 alias GroupherServer . { Accounts , CMS , Repo }
1616
1717 alias Accounts.User
18- alias CMS . { ArticleComment , ArticlePinedComment , Embeds }
18+ alias CMS . { ArticleComment , ArticlePinnedComment , Embeds }
1919 alias Ecto.Multi
2020
21- @ supported_emotions get_config ( :article , :comment_supported_emotions )
2221 @ max_participator_count ArticleComment . max_participator_count ( )
2322 @ default_emotions Embeds.ArticleCommentEmotion . default_emotions ( )
2423 @ delete_hint ArticleComment . delete_hint ( )
2524
2625 @ default_comment_meta Embeds.ArticleCommentMeta . default_meta ( )
27- @ pined_comment_limit ArticleComment . pined_comment_limit ( )
26+ @ pinned_comment_limit ArticleComment . pinned_comment_limit ( )
2827
2928 @ doc """
3029 [timeline-mode] list paged article comments
@@ -69,7 +68,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
6968 do_paged_comment_replies ( comment_id , filters , user )
7069 end
7170
72- @ spec paged_article_comments_participators ( T . comment_thread ( ) , Integer . t ( ) , T . paged_filter ( ) ) ::
71+ @ spec paged_article_comments_participators ( T . article_thread ( ) , Integer . t ( ) , T . paged_filter ( ) ) ::
7372 { :ok , T . paged_users ( ) }
7473 def paged_article_comments_participators ( thread , article_id , filters ) do
7574 % { page: page , size: size } = filters
@@ -125,7 +124,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
125124 update_article_comments_count ( comment , :dec )
126125 end )
127126 |> Multi . run ( :remove_pined_comment , fn _ , _ ->
128- ORM . findby_delete ( ArticlePinedComment , % { article_comment_id: comment . id } )
127+ ORM . findby_delete ( ArticlePinnedComment , % { article_comment_id: comment . id } )
129128 end )
130129 |> Multi . run ( :delete_article_comment , fn _ , _ ->
131130 ORM . update ( comment , % { body_html: @ delete_hint , is_deleted: true } )
@@ -236,7 +235,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
236235 } ) do
237236 with { :ok , info } <- match ( thread ) ,
238237 query <-
239- from ( p in ArticlePinedComment ,
238+ from ( p in ArticlePinnedComment ,
240239 join: c in ArticleComment ,
241240 on: p . article_comment_id == c . id ,
242241 where: field ( p , ^ info . foreign_key ) == ^ article_id ,
@@ -249,17 +248,14 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
249248
250249 _ ->
251250 preloaded_pined_comments =
252- Enum . slice ( pined_comments , 0 , @ pined_comment_limit )
251+ Enum . slice ( pined_comments , 0 , @ pinned_comment_limit )
253252 |> Repo . preload ( reply_to: :author )
254253
255- updated_entries = Enum . concat ( preloaded_pined_comments , entries )
256-
254+ entries = Enum . concat ( preloaded_pined_comments , entries )
257255 pined_comment_count = length ( pined_comments )
258256
259- Map . merge ( paged_comments , % {
260- entries: updated_entries ,
261- total_count: paged_comments . total_count + pined_comment_count
262- } )
257+ total_count = paged_comments . total_count + pined_comment_count
258+ paged_comments |> Map . merge ( % { entries: entries , total_count: total_count } )
263259 end
264260 end
265261 end
0 commit comments