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

Commit 7ee6e11

Browse files
authored
feat(blog-thread): whole-workflow (#390)
* refactor(macros): basic table setup * feat(blog-thread): basic blog tests * feat(blog-thread): extract paged_macros * feat(blog-thread): extract article in mock factory * feat(blog-thread): fix broken test cause by match order * feat(blog-thread): fix broken test * feat(blog-thread): tests for blog * feat(blog-thread): fix test * feat(blog-thread): fix test * feat(blog-thread): test wip * feat(blog-thread): test wip * feat(blog-thread): remove matcher old wip * feat(blog-thread): remove matcher old wip * feat(blog-thread): remove matcher old wip * feat(blog-thread): remove matcher old debug * feat(blog-thread): remove old post_comment && re-org PassportLoader * feat(blog-thread): remove old publish comment & macther * feat(blog-thread): wip * feat(blog-thread): clean up old post-comment * feat(blog-thread): clean up wip * feat(blog-thread): clean up wip * fix(passport): article preload loader * chore: wip * chore: wip * chore: wip * chore: wip * refactor(blog-thread): add more test * refactor(blog-thread): improve comment fold test
1 parent 5d84cf0 commit 7ee6e11

File tree

77 files changed

+3619
-1634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3619
-1634
lines changed

config/config.exs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ config :groupher_server, :customization,
6262

6363
config :groupher_server, :article,
6464
# NOTE: do not change unless you know what you are doing
65-
threads: [:post, :job, :repo],
65+
threads: [:post, :job, :repo, :blog],
6666
# in this period, paged articles will sort front if non-article-author commented
6767
# 在此时间段内,一旦有非文章作者的用户评论,该文章就会排到前面
6868
active_period_days: %{
6969
post: 10,
7070
job: 10,
71-
repo: 10
71+
repo: 10,
72+
blog: 10
7273
},
7374

7475
# NOTE: if you want to add/remove emotion, just edit the list below

lib/groupher_server/accounts/accounts.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ defmodule GroupherServer.Accounts do
4747

4848
# publish
4949
defdelegate paged_published_articles(user, thread, filter), to: Publish
50-
defdelegate published_comments(user, thread, filter), to: Publish
5150
defdelegate paged_published_article_comments(user, thread, filter), to: Publish
5251
defdelegate paged_published_article_comments(user, thread), to: Publish
5352
defdelegate update_published_states(user, thread), to: Publish

lib/groupher_server/accounts/delegates/publish.ex

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
88
import ShortMaps
99

1010
import GroupherServer.CMS.Helper.Matcher
11-
import GroupherServer.CMS.Helper.MatcherOld
1211

1312
alias GroupherServer.Accounts.Model.{Embeds, User}
1413
alias GroupherServer.CMS.Model.ArticleComment
@@ -89,20 +88,4 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
8988
|> done()
9089
end
9190
end
92-
93-
@doc """
94-
get paged published comments of a user
95-
"""
96-
def published_comments(%User{id: user_id}, thread, %{page: page, size: size} = filter) do
97-
with {:ok, user} <- ORM.find(User, user_id),
98-
{:ok, content} <- match_action(thread, :comment) do
99-
content.reactor
100-
|> join(:inner, [comment], author in assoc(comment, :author))
101-
|> where([comment, author], author.id == ^user.id)
102-
|> select([comment, author], comment)
103-
|> QueryBuilder.filter_pack(filter)
104-
|> ORM.paginater(~m(page size)a)
105-
|> done()
106-
end
107-
end
10891
end

lib/groupher_server/accounts/models/collect_folder.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ defmodule GroupherServer.Accounts.Model.CollectFolder do
33
alias __MODULE__
44

55
use Ecto.Schema
6+
use Accessible
67
import Ecto.Changeset
78

89
alias GroupherServer.{Accounts, CMS}

lib/groupher_server/cms/cms.ex

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ defmodule GroupherServer.CMS do
1818
ArticleCommentAction,
1919
ArticleCommentEmotion,
2020
ArticleTag,
21-
CommentCURD,
2221
CommunitySync,
2322
CommunityCURD,
2423
CommunityOperation,
@@ -162,14 +161,6 @@ defmodule GroupherServer.CMS do
162161
###################
163162
###################
164163
###################
165-
defdelegate create_comment(thread, content_id, args, user), to: CommentCURD
166-
defdelegate update_comment(thread, id, args, user), to: CommentCURD
167-
defdelegate delete_comment(thread, content_id), to: CommentCURD
168-
defdelegate paged_replies(thread, comment, user), to: CommentCURD
169-
defdelegate reply_comment(thread, comment, args, user), to: CommentCURD
170-
171-
defdelegate paged_comments(thread, content_id, filters), to: CommentCURD
172-
defdelegate paged_comments_participators(thread, content_id, filters), to: CommentCURD
173164

174165
# TODO: move report to abuse report module
175166
defdelegate report_article(thread, article_id, reason, attr, user), to: AbuseReport

lib/groupher_server/cms/delegates/article_comment.ex

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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, ensure: 2, get_config: 2]
6+
import Helper.Utils, only: [done: 1, ensure: 2]
77
import Helper.ErrorCode
88

99
import GroupherServer.CMS.Delegate.Helper, only: [mark_viewer_emotion_states: 3]
@@ -19,8 +19,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
1919
alias CMS.Model.{ArticleComment, ArticlePinnedComment, Embeds}
2020
alias Ecto.Multi
2121

22-
@article_threads get_config(:article, :threads)
23-
2422
@max_participator_count ArticleComment.max_participator_count()
2523
@default_emotions Embeds.ArticleCommentEmotion.default_emotions()
2624
@delete_hint ArticleComment.delete_hint()
@@ -383,7 +381,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
383381
Map.merge(paged_comments, %{entries: entries})
384382
end
385383

386-
defp set_question_flag_ifneed(%{is_question: true} = article, %ArticleComment{} = comment) do
384+
defp set_question_flag_ifneed(%{is_question: true} = _article, %ArticleComment{} = comment) do
387385
ORM.update(comment, %{is_for_question: true})
388386
end
389387

@@ -405,7 +403,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
405403
defp result({:ok, %{mark_solution: result}}), do: {:ok, result}
406404

407405
defp result({:error, :create_article_comment, result, _steps}) do
408-
raise_error(:create_comment, result)
406+
raise_error(:create_article_comment, result)
409407
end
410408

411409
defp result({:error, _, result, _steps}), do: {:error, result}

lib/groupher_server/cms/delegates/article_comment_action.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
361361
defp result({:ok, %{delete_article_comment: result}}), do: {:ok, result}
362362

363363
defp result({:error, :create_article_comment, result, _steps}) do
364-
raise_error(:create_comment, result)
364+
raise_error(:create_article_comment, result)
365365
end
366366

367367
defp result({:error, :add_participator, result, _steps}) do

lib/groupher_server/cms/delegates/comment_curd.ex

Lines changed: 0 additions & 240 deletions
This file was deleted.

0 commit comments

Comments
 (0)