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
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
6 changes: 3 additions & 3 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ config :groupher_server, :customization,

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

# NOTE: if you want to add/remove emotion, just edit the list below
# and migrate the field to table "articles_users_emotions"
supported_emotions: [
emotions: [
:upvote,
:downvote,
:beer,
Expand All @@ -86,7 +86,7 @@ config :groupher_server, :article,
],
# NOTE: if you want to add/remove emotion, just edit the list below
# and migrate the field to table "articles_comments_users_emotions"
comment_supported_emotions: [
comment_emotions: [
:downvote,
:beer,
:heart,
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/accounts/delegates/collect_folder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule GroupherServer.Accounts.Delegate.CollectFolder do
# @max_article_count_per_collect_folder 300

@default_meta Embeds.CollectFolderMeta.default_meta()
@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@doc """
list a user's not-private collect folders
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/accounts/delegates/upvoted_articles.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule GroupherServer.Accounts.Delegate.UpvotedArticles do
alias GroupherServer.CMS
alias CMS.{ArticleUpvote}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@doc """
get paged upvoted articles
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/accounts/embeds/collect_folder_meta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule GroupherServer.Accounts.Embeds.CollectFolderMeta.Macros do
"""
import Helper.Utils, only: [get_config: 2]

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

defmacro threads_fields() do
@article_threads
Expand All @@ -34,7 +34,7 @@ defmodule GroupherServer.Accounts.Embeds.CollectFolderMeta do
import GroupherServer.Accounts.Embeds.CollectFolderMeta.Macros
import Helper.Utils, only: [get_config: 2]

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@optional_fields Enum.map(@article_threads, &:"#{&1}_count") ++
Enum.map(@article_threads, &:"has_#{&1}")
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/accounts/embeds/user_meta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule GroupherServer.Accounts.Embeds.UserMeta.Macro do

import Helper.Utils, only: [get_config: 2]

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

defmacro published_article_count_fields() do
@article_threads
Expand All @@ -26,7 +26,7 @@ defmodule GroupherServer.Accounts.Embeds.UserMeta do
import GroupherServer.Accounts.Embeds.UserMeta.Macro
import Helper.Utils, only: [get_config: 2]

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@general_options %{
reported_count: 0,
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/abuse_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule GroupherServer.CMS.AbuseReport do
alias GroupherServer.{Accounts, CMS}
alias CMS.{ArticleComment, Embeds}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

# @required_fields ~w(article_comment_id user_id recived_user_id)a
@optional_fields ~w(article_comment_id account_id operate_user_id deal_with report_cases_count)a
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/article_collect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule GroupherServer.CMS.ArticleCollect do
alias GroupherServer.Accounts
alias Accounts.{User, CollectFolder}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@required_fields ~w(user_id)a
@optional_fields ~w(thread)a
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/article_comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule GroupherServer.CMS.ArticleComment do
alias CMS.{Embeds, ArticleCommentUpvote}

# alias Helper.HTML
@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@required_fields ~w(body_html author_id)a
@optional_fields ~w(reply_to_id replies_count is_folded is_deleted floor is_article_author thread)a
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/cms/article_comment_user_emotion.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule GroupherServer.CMS.ArticleCommentUserEmotion.Macros do
import Helper.Utils, only: [get_config: 2]

@supported_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :comment_emotions)

defmacro emotion_fields() do
@supported_emotions
Expand All @@ -25,7 +25,7 @@ defmodule GroupherServer.CMS.ArticleCommentUserEmotion do
alias GroupherServer.{Accounts, CMS}
alias CMS.ArticleComment

@supported_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :comment_emotions)

@required_fields ~w(article_comment_id user_id recived_user_id)a
@optional_fields Enum.map(@supported_emotions, &:"#{&1}")
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/article_pinned_comment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defmodule GroupherServer.CMS.ArticlePinnedComment do
alias CMS.ArticleComment

# alias Helper.HTML
@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@required_fields ~w(article_comment_id)a
# @optional_fields ~w(post_id job_id repo_id)a
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/article_upvote.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule GroupherServer.CMS.ArticleUpvote do
alias GroupherServer.Accounts
alias Accounts.User

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@required_fields ~w(user_id)a
@optional_fields ~w(thread)a
Expand Down
6 changes: 3 additions & 3 deletions lib/groupher_server/cms/article_user_emotion.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule GroupherServer.CMS.ArticleUserEmotion.Macros do
import Helper.Utils, only: [get_config: 2]

@supported_emotions get_config(:article, :supported_emotions)
@supported_emotions get_config(:article, :emotions)

defmacro emotion_fields() do
@supported_emotions
Expand All @@ -26,8 +26,8 @@ defmodule GroupherServer.CMS.ArticleUserEmotion do

alias GroupherServer.Accounts

@supported_emotions get_config(:article, :supported_emotions)
@article_threads get_config(:article, :article_threads)
@supported_emotions get_config(:article, :emotions)
@article_threads get_config(:article, :threads)

@required_fields ~w(user_id recived_user_id)a
@optional_fields Enum.map(@article_threads, &:"#{&1}_id") ++
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/delegates/abuse_report.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do

alias Ecto.Multi

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)
@report_threshold_for_fold ArticleComment.report_threshold_for_fold()

@export_author_keys [:id, :login, :nickname, :avatar]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do

alias Ecto.Multi

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@max_parent_replies_count ArticleComment.max_parent_replies_count()
@pinned_comment_limit ArticleComment.pinned_comment_limit()
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/delegates/community_curd.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do
}

@default_meta Embeds.CommunityMeta.default_meta()
@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

def read_community(clauses, user), do: read_community(clauses) |> viewer_has_states(user)
def read_community(%{id: id}), do: ORM.read(Community, id, inc: :views)
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/cms/delegates/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ defmodule GroupherServer.CMS.Delegate.Helper do
# TODO:
# @max_latest_emotion_users_count ArticleComment.max_latest_emotion_users_count()
@max_latest_emotion_users_count 4
@supported_emotions get_config(:article, :supported_emotions)
@supported_comment_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :emotions)
@supported_comment_emotions get_config(:article, :comment_emotions)

#######
# emotion related
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/cms/embeds/article_comment_emotion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule GroupherServer.CMS.Embeds.ArticleCommentEmotion.Macros do
alias GroupherServer.CMS
alias CMS.Embeds

@supported_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :comment_emotions)

defmacro emotion_fields() do
@supported_emotions
Expand All @@ -39,7 +39,7 @@ defmodule GroupherServer.CMS.Embeds.ArticleCommentEmotion do
import GroupherServer.CMS.Embeds.ArticleCommentEmotion.Macros
import Helper.Utils, only: [get_config: 2]

@supported_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :comment_emotions)
@optional_fields Enum.map(@supported_emotions, &:"#{&1}_count") ++
Enum.map(@supported_emotions, &:"#{&1}_user_logins")

Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/cms/embeds/article_emotion.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule GroupherServer.CMS.Embeds.ArticleEmotion.Macros do
alias GroupherServer.CMS
alias CMS.Embeds

@supported_emotions get_config(:article, :supported_emotions)
@supported_emotions get_config(:article, :emotions)

defmacro emotion_fields() do
@supported_emotions
Expand All @@ -39,7 +39,7 @@ defmodule GroupherServer.CMS.Embeds.ArticleEmotion do
import GroupherServer.CMS.Embeds.ArticleEmotion.Macros
import Helper.Utils, only: [get_config: 2]

@supported_emotions get_config(:article, :supported_emotions)
@supported_emotions get_config(:article, :emotions)

@optional_fields Enum.map(@supported_emotions, &:"#{&1}_count") ++
Enum.map(@supported_emotions, &:"#{&1}_user_logins")
Expand Down
4 changes: 2 additions & 2 deletions lib/groupher_server/cms/embeds/community_meta.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule GroupherServer.CMS.Embeds.CommunityMeta.Macro do

import Helper.Utils, only: [get_config: 2]

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

defmacro thread_count_fields() do
@article_threads
Expand All @@ -26,7 +26,7 @@ defmodule GroupherServer.CMS.Embeds.CommunityMeta do
import Helper.Utils, only: [get_config: 2]
import GroupherServer.CMS.Embeds.CommunityMeta.Macro

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@general_options %{
editors_ids: [],
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/helper/macros.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
alias Accounts.User
alias CMS.{Author, Community, ArticleComment, ArticleTag, ArticleUpvote, ArticleCollect}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@doc """
generate belongs to fields for given thread
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/helper/matcher_macros.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule GroupherServer.CMS.Helper.MatcherMacros do
alias GroupherServer.CMS
alias CMS.{ArticleComment, Embeds}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@doc """
match basic threads
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/helper/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule GroupherServer.CMS.Helper.Utils do
alias GroupherServer.CMS
alias CMS.Community

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)
@article_fields @article_threads |> Enum.map(&:"#{&1}_id")

@doc """
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server/cms/pinned_article.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule GroupherServer.CMS.PinnedArticle do
alias GroupherServer.CMS
alias CMS.Community

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@required_fields ~w(community_id thread)a
# @optional_fields ~w(post_id job_id repo_id)a
Expand Down
6 changes: 3 additions & 3 deletions lib/groupher_server_web/schema/Helper/fields.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ defmodule GroupherServerWeb.Schema.Helper.Fields do
alias GroupherServer.{Accounts, CMS}

@page_size get_config(:general, :page_size)
@supported_emotions get_config(:article, :supported_emotions)
@supported_comment_emotions get_config(:article, :comment_supported_emotions)
@supported_emotions get_config(:article, :emotions)
@supported_comment_emotions get_config(:article, :comment_emotions)

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

defmacro timestamp_fields(:article) do
quote do
Expand Down
2 changes: 1 addition & 1 deletion lib/groupher_server_web/schema/Helper/queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule GroupherServerWeb.Schema.Helper.Queries do
alias GroupherServerWeb.Middleware, as: M
alias GroupherServerWeb.Resolvers, as: R

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

# user published articles
defmacro published_article_queries() do
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/orm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Helper.ORM do
alias GroupherServer.Repo
alias Helper.{QueryBuilder, SpecType}

@article_threads get_config(:article, :article_threads)
@article_threads get_config(:article, :threads)

@doc """
a wrap for paginate request
Expand Down
4 changes: 0 additions & 4 deletions test/groupher_server/cms/articles/job_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ defmodule GroupherServer.Test.Articles.Job do
end

describe "[cms job sink/undo_sink]" do
@tag :wip2
test "if a job is too old, read job should update can_undo_sink flag",
~m(user community job_attrs)a do
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
Expand All @@ -110,7 +109,6 @@ defmodule GroupherServer.Test.Articles.Job do
assert not job_last_year.meta.can_undo_sink
end

@tag :wip2
test "can sink a job", ~m(user community job_attrs)a do
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
assert not job.meta.is_sinked
Expand All @@ -120,7 +118,6 @@ defmodule GroupherServer.Test.Articles.Job do
assert job.active_at == job.inserted_at
end

@tag :wip2
test "can undo sink job", ~m(user community job_attrs)a do
{:ok, job} = CMS.create_article(community, :job, job_attrs, user)
{:ok, job} = CMS.sink_article(:job, job.id)
Expand All @@ -132,7 +129,6 @@ defmodule GroupherServer.Test.Articles.Job do
assert job.active_at == job.meta.last_active_at
end

@tag :wip2
test "can not undo sink to old job", ~m()a do
{:ok, job_last_year} = db_insert(:job, %{title: "last year", inserted_at: @last_year})

Expand Down
1 change: 0 additions & 1 deletion test/groupher_server/cms/articles/post_meta_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ defmodule GroupherServer.Test.CMS.PostMeta do
assert post.meta.is_edited
end

@tag :wip
test "post's lock article should work", ~m(user community post_attrs)a do
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
assert not post.meta.is_comment_locked
Expand Down
4 changes: 0 additions & 4 deletions test/groupher_server/cms/articles/post_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
end

describe "[cms post sink/undo_sink]" do
@tag :wip2
test "if a post is too old, read post should update can_undo_sink flag",
~m(user community post_attrs)a do
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
Expand All @@ -120,7 +119,6 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
assert not post_last_year.meta.can_undo_sink
end

@tag :wip2
test "can sink a post", ~m(user community post_attrs)a do
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
assert not post.meta.is_sinked
Expand All @@ -130,7 +128,6 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
assert post.active_at == post.inserted_at
end

@tag :wip2
test "can undo sink post", ~m(user community post_attrs)a do
{:ok, post} = CMS.create_article(community, :post, post_attrs, user)
{:ok, post} = CMS.sink_article(:post, post.id)
Expand All @@ -142,7 +139,6 @@ defmodule GroupherServer.Test.CMS.Articles.Post do
assert post.active_at == post.meta.last_active_at
end

@tag :wip2
test "can not undo sink to old post", ~m()a do
{:ok, post_last_year} = db_insert(:post, %{title: "last year", inserted_at: @last_year})

Expand Down
Loading