Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
45fa51e
refactor(macros): basic table setup
mydearxym Jun 7, 2021
5c2b592
feat(blog-thread): basic blog tests
mydearxym Jun 7, 2021
a190b8f
feat(blog-thread): extract paged_macros
mydearxym Jun 7, 2021
4e40c17
feat(blog-thread): extract article in mock factory
mydearxym Jun 7, 2021
26cbf7d
feat(blog-thread): fix broken test cause by match order
mydearxym Jun 7, 2021
46a3144
feat(blog-thread): fix broken test
mydearxym Jun 7, 2021
be11756
feat(blog-thread): tests for blog
mydearxym Jun 7, 2021
9ffeeab
feat(blog-thread): fix test
mydearxym Jun 7, 2021
e065e41
feat(blog-thread): fix test
mydearxym Jun 7, 2021
450508a
feat(blog-thread): test wip
mydearxym Jun 7, 2021
a247e2b
feat(blog-thread): test wip
mydearxym Jun 7, 2021
68411d7
feat(blog-thread): remove matcher old wip
mydearxym Jun 7, 2021
d515f7a
feat(blog-thread): remove matcher old wip
mydearxym Jun 7, 2021
f9e04b7
feat(blog-thread): remove matcher old wip
mydearxym Jun 7, 2021
91b1495
feat(blog-thread): remove matcher old debug
mydearxym Jun 7, 2021
5893df6
feat(blog-thread): remove old post_comment && re-org PassportLoader
mydearxym Jun 7, 2021
ef6f787
feat(blog-thread): remove old publish comment & macther
mydearxym Jun 7, 2021
105fc61
feat(blog-thread): wip
mydearxym Jun 7, 2021
1d993ad
feat(blog-thread): clean up old post-comment
mydearxym Jun 7, 2021
6c698c7
feat(blog-thread): clean up wip
mydearxym Jun 7, 2021
e1a5018
feat(blog-thread): clean up wip
mydearxym Jun 7, 2021
78f27bf
fix(passport): article preload loader
mydearxym Jun 7, 2021
560c4fd
chore: wip
mydearxym Jun 7, 2021
dd47914
chore: wip
mydearxym Jun 7, 2021
6714066
chore: wip
mydearxym Jun 7, 2021
8978ddc
chore: wip
mydearxym Jun 7, 2021
fb9733e
refactor(blog-thread): add more test
mydearxym Jun 8, 2021
57c0b24
refactor(blog-thread): improve comment fold test
mydearxym Jun 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ config :groupher_server, :customization,

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

# NOTE: if you want to add/remove emotion, just edit the list below
Expand Down
1 change: 0 additions & 1 deletion lib/groupher_server/accounts/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ defmodule GroupherServer.Accounts do

# publish
defdelegate paged_published_articles(user, thread, filter), to: Publish
defdelegate published_comments(user, thread, filter), to: Publish
defdelegate paged_published_article_comments(user, thread, filter), to: Publish
defdelegate paged_published_article_comments(user, thread), to: Publish
defdelegate update_published_states(user, thread), to: Publish
Expand Down
17 changes: 0 additions & 17 deletions lib/groupher_server/accounts/delegates/publish.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
import ShortMaps

import GroupherServer.CMS.Helper.Matcher
import GroupherServer.CMS.Helper.MatcherOld

alias GroupherServer.Accounts.Model.{Embeds, User}
alias GroupherServer.CMS.Model.ArticleComment
Expand Down Expand Up @@ -89,20 +88,4 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
|> done()
end
end

@doc """
get paged published comments of a user
"""
def published_comments(%User{id: user_id}, thread, %{page: page, size: size} = filter) do
with {:ok, user} <- ORM.find(User, user_id),
{:ok, content} <- match_action(thread, :comment) do
content.reactor
|> join(:inner, [comment], author in assoc(comment, :author))
|> where([comment, author], author.id == ^user.id)
|> select([comment, author], comment)
|> QueryBuilder.filter_pack(filter)
|> ORM.paginater(~m(page size)a)
|> done()
end
end
end
1 change: 1 addition & 0 deletions lib/groupher_server/accounts/models/collect_folder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule GroupherServer.Accounts.Model.CollectFolder do
alias __MODULE__

use Ecto.Schema
use Accessible
import Ecto.Changeset

alias GroupherServer.{Accounts, CMS}
Expand Down
9 changes: 0 additions & 9 deletions lib/groupher_server/cms/cms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ defmodule GroupherServer.CMS do
ArticleCommentAction,
ArticleCommentEmotion,
ArticleTag,
CommentCURD,
CommunitySync,
CommunityCURD,
CommunityOperation,
Expand Down Expand Up @@ -162,14 +161,6 @@ defmodule GroupherServer.CMS do
###################
###################
###################
defdelegate create_comment(thread, content_id, args, user), to: CommentCURD
defdelegate update_comment(thread, id, args, user), to: CommentCURD
defdelegate delete_comment(thread, content_id), to: CommentCURD
defdelegate paged_replies(thread, comment, user), to: CommentCURD
defdelegate reply_comment(thread, comment, args, user), to: CommentCURD

defdelegate paged_comments(thread, content_id, filters), to: CommentCURD
defdelegate paged_comments_participators(thread, content_id, filters), to: CommentCURD

# TODO: move report to abuse report module
defdelegate report_article(thread, article_id, reason, attr, user), to: AbuseReport
Expand Down
8 changes: 3 additions & 5 deletions lib/groupher_server/cms/delegates/article_comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
CURD and operations for article comments
"""
import Ecto.Query, warn: false
import Helper.Utils, only: [done: 1, ensure: 2, get_config: 2]
import Helper.Utils, only: [done: 1, ensure: 2]
import Helper.ErrorCode

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

@article_threads get_config(:article, :threads)

@max_participator_count ArticleComment.max_participator_count()
@default_emotions Embeds.ArticleCommentEmotion.default_emotions()
@delete_hint ArticleComment.delete_hint()
Expand Down Expand Up @@ -383,7 +381,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
Map.merge(paged_comments, %{entries: entries})
end

defp set_question_flag_ifneed(%{is_question: true} = article, %ArticleComment{} = comment) do
defp set_question_flag_ifneed(%{is_question: true} = _article, %ArticleComment{} = comment) do
ORM.update(comment, %{is_for_question: true})
end

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

defp result({:error, :create_article_comment, result, _steps}) do
raise_error(:create_comment, result)
raise_error(:create_article_comment, result)
end

defp result({:error, _, result, _steps}), do: {:error, result}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
defp result({:ok, %{delete_article_comment: result}}), do: {:ok, result}

defp result({:error, :create_article_comment, result, _steps}) do
raise_error(:create_comment, result)
raise_error(:create_article_comment, result)
end

defp result({:error, :add_participator, result, _steps}) do
Expand Down
240 changes: 0 additions & 240 deletions lib/groupher_server/cms/delegates/comment_curd.ex

This file was deleted.

Loading