Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 1de1a89

Browse files
authored
refactor(article-comments): GQ workflow enhance && re-org (#325)
* chore(article-comments): clean up unused vars * test(article-comments): add floor & isPined test * test(article-comments): upvotes count test * test(article-comments): basic emotions test flow * test(article-comments): improve emotion test * test(article-comments): author flag & basic meta * test(article-comments): replyTo info make right * fix(article-comments): emotion perfermence issue * feat(article-comments): view has upvoted using dataloader * refactor(article-comments): rules for delete workflow * refactor(article-comments): rules for delete workflow && fix tests * refactor(article-comments): add article_comments_participators_count * refactor(article-comments): list mode wip * refactor(article-comments): timeline mode done * refactor(article-comments): re-org wip * refactor(article-comments): re-org wip * refactor(article-comments): improve replies test * fix(article-comments): replies edge case & add is_reply_to_others flag * refactor(article-comments): add list_article_comments_participators * refactor(article-comments): helper for raise custom error * refactor(article-comments): clean up
1 parent b217cdf commit 1de1a89

28 files changed

+1181
-282
lines changed

lib/groupher_server/cms/article_comment.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ defmodule GroupherServer.CMS.ArticleComment do
3535
# 每篇文章最多含有置顶评论的条数
3636
@pined_comment_limit 10
3737

38-
@doc "latest participators stores in article comment_participators field"
38+
@doc "latest participators stores in article article_comment_participators field"
3939
def max_participator_count(), do: @max_participator_count
4040
@doc "latest replies stores in article_comment replies field, used for frontend display"
4141
def max_parent_replies_count(), do: @max_parent_replies_count
@@ -52,8 +52,6 @@ defmodule GroupherServer.CMS.ArticleComment do
5252
@type t :: %ArticleComment{}
5353
schema "articles_comments" do
5454
field(:body_html, :string)
55-
field(:replies_count, :integer, default: 0)
56-
5755
# 是否被折叠
5856
field(:is_folded, :boolean, default: false)
5957
# 是否被举报
@@ -76,6 +74,8 @@ defmodule GroupherServer.CMS.ArticleComment do
7674
belongs_to(:reply_to, ArticleComment, foreign_key: :reply_to_id)
7775

7876
embeds_many(:replies, ArticleComment, on_replace: :delete)
77+
field(:replies_count, :integer, default: 0)
78+
7979
embeds_one(:emotions, Embeds.ArticleCommentEmotion, on_replace: :update)
8080
embeds_one(:meta, Embeds.ArticleCommentMeta, on_replace: :update)
8181

lib/groupher_server/cms/cms.ex

+8-5
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ defmodule GroupherServer.CMS do
109109
defdelegate unset_community(community, thread, content_id), to: ArticleOperation
110110

111111
# Comment CURD
112-
defdelegate list_article_comments(thread, article_id, filters), to: ArticleComment
113-
defdelegate list_article_comments(thread, article_id, filters, user), to: ArticleComment
112+
defdelegate list_article_comments(thread, article_id, filters, mode), to: ArticleComment
113+
defdelegate list_article_comments(thread, article_id, filters, mode, user), to: ArticleComment
114+
114115
defdelegate list_folded_article_comments(thread, article_id, filters), to: ArticleComment
115116
defdelegate list_folded_article_comments(thread, article_id, filters, user), to: ArticleComment
116117
defdelegate list_reported_article_comments(thread, article_id, filters), to: ArticleComment
@@ -119,9 +120,8 @@ defmodule GroupherServer.CMS do
119120
to: ArticleComment
120121

121122
defdelegate list_comment_replies(comment_id, filters), to: ArticleComment
122-
123-
defdelegate list_comments(thread, content_id, filters), to: CommentCURD
124-
defdelegate list_comments_participators(thread, content_id, filters), to: CommentCURD
123+
defdelegate list_comment_replies(comment_id, filters, user), to: ArticleComment
124+
defdelegate list_article_comments_participators(thread, content_id, filters), to: ArticleComment
125125

126126
defdelegate create_article_comment(thread, article_id, args, user), to: ArticleComment
127127
defdelegate upvote_article_comment(comment_id, user), to: ArticleComment
@@ -144,6 +144,9 @@ defmodule GroupherServer.CMS do
144144
defdelegate list_replies(thread, comment, user), to: CommentCURD
145145
defdelegate reply_comment(thread, comment, args, user), to: CommentCURD
146146

147+
defdelegate list_comments(thread, content_id, filters), to: CommentCURD
148+
defdelegate list_comments_participators(thread, content_id, filters), to: CommentCURD
149+
147150
# report
148151
defdelegate create_report(type, content_id, args, user), to: AbuseReport
149152

0 commit comments

Comments
 (0)