From 91ef10036db42cebdf038519b04824c7049d04fc Mon Sep 17 00:00:00 2001 From: mydearxym Date: Mon, 26 Apr 2021 16:45:25 +0800 Subject: [PATCH 1/5] refactor(drop-topic): remove from table --- .../20210426082529_remove_topic_tables.exs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 priv/repo/migrations/20210426082529_remove_topic_tables.exs diff --git a/priv/repo/migrations/20210426082529_remove_topic_tables.exs b/priv/repo/migrations/20210426082529_remove_topic_tables.exs new file mode 100644 index 000000000..381ec735e --- /dev/null +++ b/priv/repo/migrations/20210426082529_remove_topic_tables.exs @@ -0,0 +1,20 @@ +defmodule GroupherServer.Repo.Migrations.RemoveTopicTables do + use Ecto.Migration + + def change do + alter table(:tags) do + remove(:topic_id) + end + + drop(unique_index(:pined_posts, [:post_id, :community_id, :topic_id])) + + alter table(:pined_posts) do + remove(:topic_id) + end + + create(unique_index(:pined_posts, [:post_id, :community_id])) + + drop(table(:posts_topics)) + drop(table(:topics)) + end +end From a361b9f67437fda83218986f91593801641e51c8 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Mon, 26 Apr 2021 17:01:53 +0800 Subject: [PATCH 2/5] refactor(drop-topic): wip --- lib/groupher_server/cms/cms.ex | 8 --- .../cms/delegates/article_curd.ex | 26 +------- .../cms/delegates/article_operation.ex | 65 +++---------------- .../cms/delegates/community_curd.ex | 54 ++------------- lib/groupher_server/cms/pined_post.ex | 8 +-- lib/groupher_server/cms/post.ex | 13 +--- lib/groupher_server/cms/tag.ex | 7 +- lib/groupher_server/cms/topic.ex | 41 ------------ 8 files changed, 26 insertions(+), 196 deletions(-) delete mode 100644 lib/groupher_server/cms/topic.ex diff --git a/lib/groupher_server/cms/cms.ex b/lib/groupher_server/cms/cms.ex index e91e2ae03..574ab6a94 100644 --- a/lib/groupher_server/cms/cms.ex +++ b/lib/groupher_server/cms/cms.ex @@ -44,7 +44,6 @@ defmodule GroupherServer.CMS do defdelegate create_tag(community, thread, attrs, user), to: CommunityCURD defdelegate update_tag(attrs), to: CommunityCURD defdelegate get_tags(community, thread), to: CommunityCURD - defdelegate get_tags(community, thread, topic), to: CommunityCURD defdelegate get_tags(filter), to: CommunityCURD # >> wiki & cheatsheet (sync with github) defdelegate get_wiki(community), to: CommunitySync @@ -87,22 +86,15 @@ defmodule GroupherServer.CMS do # ArticleOperation # >> set flag on article, like: pin / unpin article defdelegate set_community_flags(community_info, queryable, attrs), to: ArticleOperation - defdelegate pin_content(queryable, community_id, topic), to: ArticleOperation - defdelegate undo_pin_content(queryable, community_id, topic), to: ArticleOperation defdelegate pin_content(queryable, community_id), to: ArticleOperation defdelegate undo_pin_content(queryable, community_id), to: ArticleOperation defdelegate lock_article_comment(content), to: ArticleOperation - # defdelegate pin_content(queryable, community_id, thread), to: ArticleOperation - # defdelegate undo_pin_content(queryable, community_id, thread, topic), to: ArticleOperation - # defdelegate undo_pin_content(queryable, community_id, thread), to: ArticleOperation # >> tag: set / unset defdelegate set_tag(thread, tag, content_id), to: ArticleOperation defdelegate unset_tag(thread, tag, content_id), to: ArticleOperation - defdelegate set_refined_tag(community, thread, topic, content_id), to: ArticleOperation defdelegate set_refined_tag(community, thread, content_id), to: ArticleOperation - defdelegate unset_refined_tag(community, thread, topic, content_id), to: ArticleOperation defdelegate unset_refined_tag(community, thread, content_id), to: ArticleOperation # >> community: set / unset defdelegate set_community(community, thread, content_id), to: ArticleOperation diff --git a/lib/groupher_server/cms/delegates/article_curd.ex b/lib/groupher_server/cms/delegates/article_curd.ex index e18c4d6ea..c86bdb8a1 100644 --- a/lib/groupher_server/cms/delegates/article_curd.ex +++ b/lib/groupher_server/cms/delegates/article_curd.ex @@ -11,7 +11,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do alias GroupherServer.{Accounts, CMS, Delivery, Email, Repo, Statistics} alias Accounts.User - alias CMS.{Author, Community, Embeds, Delegate, Tag, Topic} + alias CMS.{Author, Community, Embeds, Delegate, Tag} alias Delegate.ArticleOperation alias Helper.{Later, ORM, QueryBuilder} @@ -76,9 +76,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do |> Multi.run(:set_community, fn _, %{create_content: content} -> ArticleOperation.set_community(community, thread, content.id) end) - |> Multi.run(:set_topic, fn _, %{create_content: content} -> - exec_set_topic(thread, content.id, attrs) - end) |> Multi.run(:set_community_flag, fn _, %{create_content: content} -> exec_set_community_flag(community, content, action) end) @@ -294,12 +291,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do {:ok, pined_content} = CMS.PinedPost |> join(:inner, [p], c in assoc(p, :community)) - |> join(:inner, [p], t in assoc(p, :topic)) |> join(:inner, [p], content in assoc(p, :post)) - |> where( - [p, c, t, content], - c.raw == ^community and t.raw == ^Map.get(filter, :topic, "posts") - ) + |> where([p, c, t, content], c.raw == ^community) |> select([p, c, t, content], content) # 10 pined contents per community/thread, at most |> ORM.paginater(%{page: 1, size: 10}) @@ -348,7 +341,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do defp should_add_pin?(%{page: 1, tag: :all, sort: :desc_inserted, read: :all} = filter) do filter |> Map.keys() - |> Enum.reject(fn x -> x in [:community, :tag, :sort, :read, :topic, :page, :size] end) + |> Enum.reject(fn x -> x in [:community, :tag, :sort, :read, :page, :size] end) |> case do [] -> {:ok, :pass} _ -> {:error, :pass} @@ -403,10 +396,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do {:error, [message: "set community flag", code: ecode(:create_fails)]} end - defp create_content_result({:error, :set_topic, _result, _steps}) do - {:error, [message: "set topic", code: ecode(:create_fails)]} - end - defp create_content_result({:error, :set_tag, result, _steps}) do {:error, result} end @@ -434,15 +423,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do |> Repo.insert() end - defp exec_set_topic(thread, id, %{topic: topic}) do - ArticleOperation.set_topic(%Topic{title: topic}, thread, id) - end - - # if topic is not provide, use posts as default - defp exec_set_topic(thread, id, _attrs) do - ArticleOperation.set_topic(%Topic{title: "posts"}, thread, id) - end - defp exec_set_tag(thread, id, %{tags: tags}) do try do Enum.each(tags, fn tag -> diff --git a/lib/groupher_server/cms/delegates/article_operation.ex b/lib/groupher_server/cms/delegates/article_operation.ex index 7a39d9a75..e33c3ec9b 100644 --- a/lib/groupher_server/cms/delegates/article_operation.ex +++ b/lib/groupher_server/cms/delegates/article_operation.ex @@ -18,7 +18,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do JobCommunityFlag, RepoCommunityFlag, Tag, - Topic, PinedPost, PinedJob, PinedRepo @@ -27,13 +26,12 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do alias GroupherServer.CMS.Repo, as: CMSRepo alias GroupherServer.Repo - def pin_content(%Post{id: post_id}, %Community{id: community_id}, topic) do - with {:ok, %{id: topic_id}} <- ORM.find_by(Topic, %{raw: topic}), - {:ok, pined} <- + def pin_content(%Post{id: post_id}, %Community{id: community_id}) do + with {:ok, pined} <- ORM.findby_or_insert( PinedPost, - ~m(post_id community_id topic_id)a, - ~m(post_id community_id topic_id)a + ~m(post_id community_id)a, + ~m(post_id community_id)a ) do Post |> ORM.find(pined.post_id) end @@ -55,9 +53,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do end end - def undo_pin_content(%Post{id: post_id}, %Community{id: community_id}, topic) do - with {:ok, %{id: topic_id}} <- ORM.find_by(Topic, %{raw: topic}), - {:ok, pined} <- ORM.find_by(PinedPost, ~m(post_id community_id topic_id)a), + def undo_pin_content(%Post{id: post_id}, %Community{id: community_id}) do + with {:ok, pined} <- ORM.find_by(PinedPost, ~m(post_id community_id)a), {:ok, deleted} <- ORM.delete(pined) do Post |> ORM.find(deleted.post_id) end @@ -177,55 +174,33 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do @doc """ set refined_tag to common content """ - def set_refined_tag(%Community{id: community_id}, thread, topic_raw, content_id) do + def set_refined_tag(%Community{id: community_id}, thread, content_id) do with {:ok, action} <- match_action(thread, :tag), {:ok, content} <- ORM.find(action.target, content_id, preload: :tags), - {:ok, topic} <- ORM.find_by(Topic, %{raw: topic_raw}), {:ok, tag} <- ORM.find_by(action.reactor, %{ title: "refined", - community_id: community_id, - topic_id: topic.id + community_id: community_id }) do update_content_tag(content, tag) end end - def set_refined_tag(%Community{id: community_id}, thread, content_id) do - with {:ok, action} <- match_action(thread, :tag), - {:ok, content} <- ORM.find(action.target, content_id, preload: :tags), - {:ok, tag} <- - ORM.find_by(action.reactor, %{title: "refined", community_id: community_id}) do - update_content_tag(content, tag) - end - end - @doc """ unset refined_tag to common content """ - def unset_refined_tag(%Community{id: community_id}, thread, topic_raw, content_id) do + def unset_refined_tag(%Community{id: community_id}, thread, content_id) do with {:ok, action} <- match_action(thread, :tag), {:ok, content} <- ORM.find(action.target, content_id, preload: :tags), - {:ok, topic} <- ORM.find_by(Topic, %{raw: topic_raw}), {:ok, tag} <- ORM.find_by(action.reactor, %{ title: "refined", - community_id: community_id, - topic_id: topic.id + community_id: community_id }) do update_content_tag(content, tag, :drop) end end - def unset_refined_tag(%Community{id: community_id}, thread, content_id) do - with {:ok, action} <- match_action(thread, :tag), - {:ok, content} <- ORM.find(action.target, content_id, preload: :tags), - {:ok, tag} <- - ORM.find_by(action.reactor, %{title: "refined", community_id: community_id}) do - update_content_tag(content, tag, :drop) - end - end - defp update_content_tag(content, %Tag{} = tag, opt \\ :add) do new_tags = if opt == :add, do: content.tags ++ [tag], else: content.tags -- [tag] @@ -235,26 +210,6 @@ defmodule GroupherServer.CMS.Delegate.ArticleOperation do |> Repo.update() end - @doc """ - set topic only for post - """ - def set_topic(%Topic{title: title}, :post, content_id) do - with {:ok, content} <- ORM.find(Post, content_id, preload: :topics), - {:ok, topic} <- - ORM.findby_or_insert(Topic, %{title: title}, %{ - title: title, - thread: "post", - raw: title - }) do - content - |> Ecto.Changeset.change() - |> Ecto.Changeset.put_assoc(:topics, content.topics ++ [topic]) - |> Repo.update() - end - end - - def set_topic(_topic, _thread, _content_id), do: {:ok, :pass} - @doc "update isEdited meta label if needed" # TODO: diff history def update_edit_status(%{meta: %Embeds.ArticleMeta{is_edited: false} = meta} = content) do diff --git a/lib/groupher_server/cms/delegates/community_curd.ex b/lib/groupher_server/cms/delegates/community_curd.ex index d838839ae..b57249720 100644 --- a/lib/groupher_server/cms/delegates/community_curd.ex +++ b/lib/groupher_server/cms/delegates/community_curd.ex @@ -18,7 +18,6 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do CommunityEditor, CommunitySubscriber, Tag, - Topic, Thread } @@ -63,11 +62,10 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do def create_tag(%Community{id: community_id}, thread, attrs, %Accounts.User{id: user_id}) do with {:ok, action} <- match_action(thread, :tag), {:ok, author} <- ensure_author_exists(%Accounts.User{id: user_id}), - {:ok, _community} <- ORM.find(Community, community_id), - {:ok, topic} = find_or_insert_topic(attrs) do + {:ok, _community} <- ORM.find(Community, community_id) do attrs = attrs - |> Map.merge(%{author_id: author.id, topic_id: topic.id, community_id: community_id}) + |> Map.merge(%{author_id: author.id, community_id: community_id}) |> map_atom_value(:string) |> Map.merge(%{thread: thread |> to_string |> String.downcase()}) @@ -78,10 +76,8 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do def update_tag(%{id: _id} = attrs) do ~m(id title color)a = attrs |> map_atom_value(:string) - with {:ok, %{id: topic_id}} = find_or_insert_topic(attrs) do - Tag - |> ORM.find_update(~m(id title color topic_id)a) - end + Tag + |> ORM.find_update(~m(id title color)a) end @doc """ @@ -116,31 +112,12 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do @doc """ get tags belongs to a community / thread """ - def get_tags(%Community{id: community_id}, thread, topic) when not is_nil(community_id) do - # thread = thread |> to_string |> String.upcase() - # topic = topic |> to_string |> String.upcase() + def get_tags(%Community{raw: community_raw}, thread) when not is_nil(community_raw) do thread = thread |> to_string |> String.downcase() - topic = topic |> to_string |> String.downcase() Tag |> join(:inner, [t], c in assoc(t, :community)) - |> join(:inner, [t], cp in assoc(t, :topic)) - |> where([t, c, cp], c.id == ^community_id and t.thread == ^thread and cp.title == ^topic) - |> distinct([t], t.title) - |> Repo.all() - |> done() - end - - def get_tags(%Community{raw: community_raw}, thread, topic) when not is_nil(community_raw) do - # thread = thread |> to_string |> String.upcase() - # topic = topic |> to_string |> String.upcase() - thread = thread |> to_string |> String.downcase() - topic = topic |> to_string |> String.downcase() - - Tag - |> join(:inner, [t], c in assoc(t, :community)) - |> join(:inner, [t], cp in assoc(t, :topic)) - |> where([t, c, cp], c.raw == ^community_raw and t.thread == ^thread and cp.title == ^topic) + |> where([t, c], c.raw == ^community_raw and t.thread == ^thread) |> distinct([t], t.title) |> Repo.all() |> done() @@ -248,25 +225,6 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do end end - defp find_or_insert_topic(%{topic: title} = attrs) when is_binary(title) do - title = title |> to_string() |> String.downcase() - thread = attrs.thread |> to_string() |> String.downcase() - - ORM.findby_or_insert(Topic, %{title: title}, %{ - title: title, - thread: thread, - raw: title - }) - end - - defp find_or_insert_topic(%{thread: thread}) do - find_or_insert_topic(%{topic: "posts", thread: thread}) - end - - defp find_or_insert_topic(_attrs) do - find_or_insert_topic(%{topic: "posts", thread: :post}) - end - defp load_community_members(%Community{id: id}, queryable, %{page: page, size: size} = filters) when not is_nil(id) do queryable diff --git a/lib/groupher_server/cms/pined_post.ex b/lib/groupher_server/cms/pined_post.ex index 073052f7a..f93236070 100644 --- a/lib/groupher_server/cms/pined_post.ex +++ b/lib/groupher_server/cms/pined_post.ex @@ -6,16 +6,14 @@ defmodule GroupherServer.CMS.PinedPost do import Ecto.Changeset alias GroupherServer.CMS - alias CMS.{Community, Post, Topic} + alias CMS.{Community, Post} @required_fields ~w(post_id community_id)a - @optional_fields ~w(topic_id)a @type t :: %PinedPost{} schema "pined_posts" do belongs_to(:post, Post, foreign_key: :post_id) belongs_to(:community, Community, foreign_key: :community_id) - belongs_to(:topic, Topic, foreign_key: :topic_id) timestamps(type: :utc_datetime) end @@ -23,10 +21,10 @@ defmodule GroupherServer.CMS.PinedPost do @doc false def changeset(%PinedPost{} = pined_post, attrs) do pined_post - |> cast(attrs, @optional_fields ++ @required_fields) + |> cast(attrs, @required_fields) |> validate_required(@required_fields) |> foreign_key_constraint(:post_id) |> foreign_key_constraint(:community_id) - |> unique_constraint(:pined_posts, name: :pined_posts_post_id_community_id_topic_id_index) + |> unique_constraint(:pined_posts, name: :pined_posts_post_id_community_id_index) end end diff --git a/lib/groupher_server/cms/post.ex b/lib/groupher_server/cms/post.ex index 17873b0b2..3089f567f 100644 --- a/lib/groupher_server/cms/post.ex +++ b/lib/groupher_server/cms/post.ex @@ -20,8 +20,7 @@ defmodule GroupherServer.CMS.Post do PostFavorite, PostStar, PostViewer, - Tag, - Topic + Tag } alias Helper.HTML @@ -78,16 +77,6 @@ defmodule GroupherServer.CMS.Post do on_replace: :delete ) - many_to_many( - :topics, - Topic, - join_through: "posts_topics", - join_keys: [post_id: :id, topic_id: :id], - # :delete_all will only remove data from the join source - on_delete: :delete_all, - on_replace: :delete - ) - belongs_to(:origial_community, Community) many_to_many( diff --git a/lib/groupher_server/cms/tag.ex b/lib/groupher_server/cms/tag.ex index 79dac5be1..e6e660c18 100644 --- a/lib/groupher_server/cms/tag.ex +++ b/lib/groupher_server/cms/tag.ex @@ -6,9 +6,9 @@ defmodule GroupherServer.CMS.Tag do import Ecto.Changeset alias GroupherServer.CMS - alias CMS.{Author, Community, Topic, Job, Post} + alias CMS.{Author, Community, Job, Post} - @required_fields ~w(thread title color author_id topic_id community_id)a + @required_fields ~w(thread title color author_id community_id)a # @required_fields ~w(thread title color author_id community_id)a @type t :: %Tag{} @@ -17,7 +17,6 @@ defmodule GroupherServer.CMS.Tag do field(:color, :string) field(:thread, :string) belongs_to(:community, Community) - belongs_to(:topic, Topic) belongs_to(:author, Author) many_to_many( @@ -46,7 +45,7 @@ defmodule GroupherServer.CMS.Tag do |> validate_required(@required_fields) |> foreign_key_constraint(:user_id) |> foreign_key_constraint(:community_id) - |> unique_constraint(:tag_duplicate, name: :tags_community_id_thread_topic_id_title_index) + |> unique_constraint(:tag_duplicate, name: :tags_community_id_thread_title_index) # |> foreign_key_constraint(name: :posts_tags_tag_id_fkey) end diff --git a/lib/groupher_server/cms/topic.ex b/lib/groupher_server/cms/topic.ex deleted file mode 100644 index 8459af3bf..000000000 --- a/lib/groupher_server/cms/topic.ex +++ /dev/null @@ -1,41 +0,0 @@ -defmodule GroupherServer.CMS.Topic do - @moduledoc false - alias __MODULE__ - - use Ecto.Schema - import Ecto.Changeset - - @required_fields ~w(thread title raw)a - - @type t :: %Topic{} - schema "topics" do - field(:title, :string) - field(:thread, :string) - field(:raw, :string) - - # many_to_many( - # :posts, - # Post, - # join_through: "posts_tags", - # join_keys: [post_id: :id, tag_id: :id], - # on_delete: :delete_all - # ) - - # many_to_many( - # :jobs, - # Job, - # join_through: "jobs_tags", - # join_keys: [job_id: :id, tag_id: :id] - # ) - - timestamps(type: :utc_datetime) - end - - def changeset(%Topic{} = topic, attrs) do - topic - |> cast(attrs, @required_fields) - |> validate_required(@required_fields) - - # |> unique_constraint(:tag_duplicate, name: :tags_community_id_thread_title_index) - end -end From 21dfd980fcddaacd1ca77a8b0a24b47dcf0f5881 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Mon, 26 Apr 2021 20:11:55 +0800 Subject: [PATCH 3/5] refactor(drop-topic): wip --- .../cms/delegates/seeds_config.ex | 20 +-- .../middleware/add_source_icon.ex | 41 ------ .../resolvers/cms_resolver.ex | 28 ++-- .../schema/cms/cms_misc.ex | 2 - .../schema/cms/cms_queries.ex | 1 - .../schema/cms/cms_types.ex | 8 -- .../schema/cms/mutations/community.ex | 1 - .../schema/cms/mutations/operation.ex | 2 - .../schema/cms/mutations/post.ex | 4 - lib/helper/query_builder.ex | 7 - priv/mock/tag_patch_seeds.exs | 6 +- .../mutation/cms/cms_test.exs | 29 +--- .../mutation/cms/job_test.exs | 8 +- .../mutation/cms/post_test.exs | 54 +------- .../mutation/cms/radar_test.exs | 11 +- .../mutation/statistics/statistics_test.exs | 2 - .../query/cms/cms_test.exs | 8 +- .../query/cms/posts_topic_test.exs | 125 ------------------ 18 files changed, 38 insertions(+), 319 deletions(-) delete mode 100644 lib/groupher_server_web/middleware/add_source_icon.ex delete mode 100644 test/groupher_server_web/query/cms/posts_topic_test.exs diff --git a/lib/groupher_server/cms/delegates/seeds_config.ex b/lib/groupher_server/cms/delegates/seeds_config.ex index 386b15b0c..1819698c8 100644 --- a/lib/groupher_server/cms/delegates/seeds_config.ex +++ b/lib/groupher_server/cms/delegates/seeds_config.ex @@ -294,7 +294,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end) end def tags(:job) do @@ -305,7 +305,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :cadetblue } ]) - |> Enum.map(fn attr -> Map.merge(%{thread: :job, topic: "jobs"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :job}, attr) end) end def tags(:repo) do @@ -343,7 +343,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :repo, topic: "repos"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :repo}, attr) end) end def tags(_), do: [] @@ -383,7 +383,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end) end # home posts @@ -422,7 +422,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end) end def tags(:home, :tech) do @@ -460,7 +460,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :tech, topic: "tech"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :tech}, attr) end) end def tags(:home, :share) do @@ -498,7 +498,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :share, topic: "share"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :share}, attr) end) end def tags(:home, :radar) do @@ -537,12 +537,12 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :grey } ] - |> Enum.map(fn attr -> Map.merge(%{thread: :radar, topic: "radar"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :radar}, attr) end) end def tags(:home, :city) do city_tags() - |> Enum.map(fn attr -> Map.merge(%{thread: :city, topic: "city"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :city}, attr) end) end def tags(:home, :job) do @@ -553,7 +553,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do color: :cadetblue } ]) - |> Enum.map(fn attr -> Map.merge(%{thread: :job, topic: "jobs"}, attr) end) + |> Enum.map(fn attr -> Map.merge(%{thread: :job}, attr) end) end def tags(:home, _), do: [] diff --git a/lib/groupher_server_web/middleware/add_source_icon.ex b/lib/groupher_server_web/middleware/add_source_icon.ex deleted file mode 100644 index 64e9013ea..000000000 --- a/lib/groupher_server_web/middleware/add_source_icon.ex +++ /dev/null @@ -1,41 +0,0 @@ -# --- -# parse and add source icon to radar posts -# --- -defmodule GroupherServerWeb.Middleware.AddSourceIcon do - @moduledoc """ - parse and add source icon to radar posts - """ - @behaviour Absinthe.Middleware - - @parse_error "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/url_parse_waning.png" - @wanqu "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/wanqu.png" - @solidot "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/solidot.png" - @techcrunch "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/techcrunch.png" - @default_radar "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/default_radar.png" - - def call(%{arguments: %{topic: "radar"} = arguments} = resolution, _) do - link_icon = parse_source_addr(arguments) - %{resolution | arguments: Map.merge(arguments, %{link_icon: link_icon})} - end - - def call(resolution, _), do: resolution - - defp parse_source_addr(%{link_addr: link_addr}) do - result = URI.parse(link_addr) - - case Map.get(result, :host) do - nil -> source_addr(:error) - host -> source_addr(host) - end - end - - defp parse_source_addr(_), do: @default_radar - - defp source_addr("wanqu.co"), do: @wanqu - defp source_addr("www.solidot.org"), do: @solidot - defp source_addr("techcrunch.cn"), do: @techcrunch - defp source_addr("techcrunch.com"), do: @techcrunch - - defp source_addr(:error), do: @parse_error - defp source_addr(_), do: @default_radar -end diff --git a/lib/groupher_server_web/resolvers/cms_resolver.ex b/lib/groupher_server_web/resolvers/cms_resolver.ex index 5e08a1b84..d1b8d5304 100644 --- a/lib/groupher_server_web/resolvers/cms_resolver.ex +++ b/lib/groupher_server_web/resolvers/cms_resolver.ex @@ -99,16 +99,16 @@ defmodule GroupherServerWeb.Resolvers.CMS do # ####################### # content flag .. # ####################### - def pin_content(_root, ~m(id community_id topic)a, _info) do - CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}, topic) + def pin_content(_root, ~m(id community_id)a, _info) do + CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}) end def pin_content(_root, ~m(id community_id thread)a, _info) do do_pin_content(id, community_id, thread) end - def undo_pin_content(_root, ~m(id community_id topic)a, _info) do - CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}, topic) + def undo_pin_content(_root, ~m(id community_id)a, _info) do + CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}) end def undo_pin_content(_root, ~m(id community_id thread)a, _info) do @@ -251,10 +251,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.set_tag(thread, %Tag{id: tag_id}, id) end - def set_refined_tag(_root, ~m(community_id thread id topic)a, _info) do - CMS.set_refined_tag(%Community{id: community_id}, thread, topic, id) - end - def set_refined_tag(_root, ~m(community_id thread id)a, _info) do CMS.set_refined_tag(%Community{id: community_id}, thread, id) end @@ -263,10 +259,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.unset_tag(thread, %Tag{id: tag_id}, id) end - def unset_refined_tag(_root, ~m(community_id thread id topic)a, _info) do - CMS.unset_refined_tag(%Community{id: community_id}, thread, topic, id) - end - def unset_refined_tag(_root, ~m(community_id thread id)a, _info) do CMS.unset_refined_tag(%Community{id: community_id}, thread, id) end @@ -279,14 +271,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.get_tags(%Community{raw: community}) end - def get_tags(_root, ~m(community_id thread topic)a, _info) do - CMS.get_tags(%Community{id: community_id}, thread, topic) - end - - def get_tags(_root, ~m(community thread topic)a, _info) do - CMS.get_tags(%Community{raw: community}, thread, topic) - end - def get_tags(_root, ~m(community_id thread)a, _info) do CMS.get_tags(%Community{id: community_id}, thread) end @@ -295,6 +279,10 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.get_tags(%Community{raw: community}, thread) end + def get_tags(_root, ~m(community_id thread)a, _info) do + CMS.get_tags(%Community{id: community_id}, thread) + end + def get_tags(_root, %{thread: _thread}, _info) do {:error, "community_id or community is needed"} end diff --git a/lib/groupher_server_web/schema/cms/cms_misc.ex b/lib/groupher_server_web/schema/cms/cms_misc.ex index c5bcf2d39..662627c8b 100644 --- a/lib/groupher_server_web/schema/cms/cms_misc.ex +++ b/lib/groupher_server_web/schema/cms/cms_misc.ex @@ -226,8 +226,6 @@ defmodule GroupherServerWeb.Schema.CMS.Misc do pagination_args() article_filter_fields() field(:sort, :sort_enum) - - field(:topic, :string) end @desc "job_filter doc" diff --git a/lib/groupher_server_web/schema/cms/cms_queries.ex b/lib/groupher_server_web/schema/cms/cms_queries.ex index e316f5338..a9acf2fe1 100644 --- a/lib/groupher_server_web/schema/cms/cms_queries.ex +++ b/lib/groupher_server_web/schema/cms/cms_queries.ex @@ -154,7 +154,6 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do arg(:community_id, :id) arg(:community, :string) arg(:thread, :cms_thread, default_value: :post) - arg(:topic, :string) arg(:all, :boolean, default_value: false) resolve(&R.CMS.get_tags/3) diff --git a/lib/groupher_server_web/schema/cms/cms_types.ex b/lib/groupher_server_web/schema/cms/cms_types.ex index 9f3fe7baf..49b5525d8 100644 --- a/lib/groupher_server_web/schema/cms/cms_types.ex +++ b/lib/groupher_server_web/schema/cms/cms_types.ex @@ -42,7 +42,6 @@ defmodule GroupherServerWeb.Schema.CMS.Types do field(:author, :user, resolve: dataloader(CMS, :author)) field(:origial_community, :community, resolve: dataloader(CMS, :origial_community)) field(:communities, list_of(:community), resolve: dataloader(CMS, :communities)) - # field(:topic) field(:meta, :article_meta) field(:article_comments_participators, list_of(:user)) @@ -312,12 +311,6 @@ defmodule GroupherServerWeb.Schema.CMS.Types do timestamp_fields() end - object :topic do - field(:id, :id) - field(:title, :string) - field(:raw, :string) - end - object :tag do field(:id, :id) field(:title, :string) @@ -325,7 +318,6 @@ defmodule GroupherServerWeb.Schema.CMS.Types do field(:thread, :string) field(:author, :user, resolve: dataloader(CMS, :author)) field(:community, :community, resolve: dataloader(CMS, :community)) - field(:topic, :topic, resolve: dataloader(CMS, :topic)) timestamp_fields() end diff --git a/lib/groupher_server_web/schema/cms/mutations/community.ex b/lib/groupher_server_web/schema/cms/mutations/community.ex index 2ce12f5ee..98d95ce58 100644 --- a/lib/groupher_server_web/schema/cms/mutations/community.ex +++ b/lib/groupher_server_web/schema/cms/mutations/community.ex @@ -132,7 +132,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do arg(:color, non_null(:rainbow_color_enum)) arg(:community_id, non_null(:id)) arg(:thread, :cms_thread, default_value: :post) - arg(:topic, :string, default_value: "posts") middleware(M.Authorize, :login) middleware(M.PassportLoader, source: :community) diff --git a/lib/groupher_server_web/schema/cms/mutations/operation.ex b/lib/groupher_server_web/schema/cms/mutations/operation.ex index e1a3a4abb..a247dc750 100644 --- a/lib/groupher_server_web/schema/cms/mutations/operation.ex +++ b/lib/groupher_server_web/schema/cms/mutations/operation.ex @@ -98,7 +98,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do arg(:id, non_null(:id)) arg(:community_id, non_null(:id)) arg(:thread, :cms_thread, default_value: :post) - arg(:topic, :string) middleware(M.Authorize, :login) middleware(M.PassportLoader, source: :community) @@ -127,7 +126,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do arg(:id, non_null(:id)) arg(:community_id, non_null(:id)) arg(:thread, :cms_thread, default_value: :post) - arg(:topic, :string) middleware(M.Authorize, :login) middleware(M.PassportLoader, source: :community) diff --git a/lib/groupher_server_web/schema/cms/mutations/post.ex b/lib/groupher_server_web/schema/cms/mutations/post.ex index b1575f4f1..11fdc57c0 100644 --- a/lib/groupher_server_web/schema/cms/mutations/post.ex +++ b/lib/groupher_server_web/schema/cms/mutations/post.ex @@ -15,13 +15,11 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do arg(:copy_right, :string) arg(:community_id, non_null(:id)) arg(:thread, :cms_thread, default_value: :post) - arg(:topic, :string, default_value: "posts") arg(:tags, list_of(:ids)) arg(:mention_users, list_of(:ids)) middleware(M.Authorize, :login) # middleware(M.PublishThrottle) - middleware(M.AddSourceIcon) middleware(M.PublishThrottle, interval: 3, hour_limit: 15, day_limit: 30) resolve(&R.CMS.create_content/3) middleware(M.Statistics.MakeContribute, for: [:user, :community]) @@ -32,7 +30,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do arg(:id, non_null(:id)) arg(:community_id, non_null(:id)) arg(:thread, :post_thread, default_value: :post) - arg(:topic, :string, default_value: "posts") middleware(M.Authorize, :login) middleware(M.PassportLoader, source: :community) @@ -45,7 +42,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do arg(:id, non_null(:id)) arg(:thread, :post_thread, default_value: :post) arg(:community_id, non_null(:id)) - arg(:topic, :string, default_value: "posts") middleware(M.Authorize, :login) middleware(M.PassportLoader, source: :community) diff --git a/lib/helper/query_builder.ex b/lib/helper/query_builder.ex index 97c5a77b8..bb34c1fd7 100644 --- a/lib/helper/query_builder.ex +++ b/lib/helper/query_builder.ex @@ -182,13 +182,6 @@ defmodule Helper.QueryBuilder do where: t.title == ^tag_name ) - {:topic, topic}, queryable -> - from( - q in queryable, - join: t in assoc(q, :topics), - where: t.raw == ^topic - ) - {:category, catetory_raw}, queryable -> from( q in queryable, diff --git a/priv/mock/tag_patch_seeds.exs b/priv/mock/tag_patch_seeds.exs index bb9bfcc6b..a162171d8 100644 --- a/priv/mock/tag_patch_seeds.exs +++ b/priv/mock/tag_patch_seeds.exs @@ -17,14 +17,12 @@ patch_tags = [ %{ title: "docs", color: :blue, - thread: :repo, - topic: "repos" + thread: :repo }, %{ title: "tuts", color: :purple, - thread: :repo, - topic: "repos" + thread: :repo } ] diff --git a/test/groupher_server_web/mutation/cms/cms_test.exs b/test/groupher_server_web/mutation/cms/cms_test.exs index 7485d0b5a..3928b3041 100644 --- a/test/groupher_server_web/mutation/cms/cms_test.exs +++ b/test/groupher_server_web/mutation/cms/cms_test.exs @@ -185,15 +185,12 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do describe "[mutation cms tag]" do @create_tag_query """ - mutation($thread: CmsThread!, $title: String!, $color: RainbowColorEnum!, $communityId: ID!, $topic: String) { - createTag(thread: $thread, title: $title, color: $color, communityId: $communityId, topic: $topic) { + mutation($thread: CmsThread!, $title: String!, $color: RainbowColorEnum!, $communityId: ID!) { + createTag(thread: $thread, title: $title, color: $color, communityId: $communityId) { id title color thread - topic { - title - } community { id logo @@ -202,7 +199,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do } } """ - test "create tag with valid attrs, has default POST thread and default posts topic", + test "create tag with valid attrs, has default POST thread and default posts", ~m(community)a do variables = mock_attrs(:tag, %{communityId: community.id}) @@ -216,29 +213,9 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do assert created["id"] == to_string(found.id) assert found.thread == "post" - assert created["topic"]["title"] == "posts" assert belong_community["id"] == to_string(community.id) end - test "can create some tag on different topic", ~m(community)a do - variables = mock_attrs(:tag, %{communityId: community.id, topic: "city"}) - - passport_rules = %{community.title => %{"post.tag.create" => true}} - rule_conn = simu_conn(:user, cms: passport_rules) - - created = rule_conn |> mutation_result(@create_tag_query, variables, "createTag") - assert created["title"] == variables.title - assert created["topic"]["title"] == "city" - - assert rule_conn - |> mutation_get_error?(@create_tag_query, variables) - - variables = variables |> Map.merge(%{topic: "radar"}) - created = rule_conn |> mutation_result(@create_tag_query, variables, "createTag") - assert created["title"] == variables.title - assert created["topic"]["title"] == "radar" - end - test "auth user create duplicate tag fails", ~m(community)a do variables = mock_attrs(:tag, %{communityId: community.id}) diff --git a/test/groupher_server_web/mutation/cms/job_test.exs b/test/groupher_server_web/mutation/cms/job_test.exs index 054ef0621..7fafe0aee 100644 --- a/test/groupher_server_web/mutation/cms/job_test.exs +++ b/test/groupher_server_web/mutation/cms/job_test.exs @@ -310,8 +310,8 @@ defmodule GroupherServer.Test.Mutation.Job do } """ @set_refined_tag_query """ - mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) { - setRefinedTag(communityId: $communityId, thread: $thread, topic: $topic, id: $id) { + mutation($communityId: ID!, $thread: CmsThread, $id: ID!) { + setRefinedTag(communityId: $communityId, thread: $thread, id: $id) { id title } @@ -393,8 +393,8 @@ defmodule GroupherServer.Test.Mutation.Job do end @unset_refined_tag_query """ - mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) { - unsetRefinedTag(communityId: $communityId, thread: $thread, topic: $topic, id: $id) { + mutation($communityId: ID!, $thread: CmsThread, $id: ID!) { + unsetRefinedTag(communityId: $communityId, thread: $thread, id: $id) { id title } diff --git a/test/groupher_server_web/mutation/cms/post_test.exs b/test/groupher_server_web/mutation/cms/post_test.exs index f22da812e..36e8191c3 100644 --- a/test/groupher_server_web/mutation/cms/post_test.exs +++ b/test/groupher_server_web/mutation/cms/post_test.exs @@ -25,7 +25,6 @@ defmodule GroupherServer.Test.Mutation.Post do $communityId: ID! $tags: [Ids] $mentionUsers: [Ids] - $topic: String ) { createPost( title: $title @@ -35,7 +34,6 @@ defmodule GroupherServer.Test.Mutation.Post do communityId: $communityId tags: $tags mentionUsers: $mentionUsers - topic: $topic ) { title body @@ -335,8 +333,8 @@ defmodule GroupherServer.Test.Mutation.Post do } """ @set_refined_tag_query """ - mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) { - setRefinedTag(communityId: $communityId, thread: $thread, topic: $topic, id: $id) { + mutation($communityId: ID!, $thread: CmsThread, $id: ID!) { + setRefinedTag(communityId: $communityId, thread: $thread, id: $id) { id title } @@ -384,26 +382,6 @@ defmodule GroupherServer.Test.Mutation.Post do assert tag.id in assoc_tags end - test "auth user can set refined tag to post of spec topic", ~m(post)a do - {:ok, community} = db_insert(:community) - {:ok, user} = db_insert(:user) - - tag_attrs = - mock_attrs(:tag, %{thread: "post", community: community, title: "refined", topic: "tech"}) - - {:ok, tag} = CMS.create_tag(community, :post, tag_attrs, user) - - passport_rules = %{community.title => %{"post.refinedtag.set" => true}} - rule_conn = simu_conn(:user, cms: passport_rules) - - variables = %{id: post.id, communityId: community.id, topic: "tech"} - rule_conn |> mutation_result(@set_refined_tag_query, variables, "setRefinedTag") - {:ok, found} = ORM.find(CMS.Post, post.id, preload: :tags) - - assoc_tags = found.tags |> Enum.map(& &1.id) - assert tag.id in assoc_tags - end - # TODO: should fix in auth layer # test "auth user set a other community tag to post fails", ~m(post)a do # {:ok, community} = db_insert(:community) @@ -446,8 +424,8 @@ defmodule GroupherServer.Test.Mutation.Post do } """ @unset_refined_tag_query """ - mutation($communityId: ID!, $thread: CmsThread, $topic: String, $id: ID!) { - unsetRefinedTag(communityId: $communityId, thread: $thread, topic: $topic, id: $id) { + mutation($communityId: ID!, $thread: CmsThread, $id: ID!) { + unsetRefinedTag(communityId: $communityId, thread: $thread, id: $id) { id title } @@ -504,30 +482,6 @@ defmodule GroupherServer.Test.Mutation.Post do assoc_tags = found.tags |> Enum.map(& &1.id) assert tag.id not in assoc_tags end - - test "can unset refined tag to a post of spec topic", ~m(post)a do - {:ok, community} = db_insert(:community) - {:ok, user} = db_insert(:user) - - tag_attrs = - mock_attrs(:tag, %{thread: "post", community: community, title: "refined", topic: "tech"}) - - {:ok, tag} = CMS.create_tag(community, :post, tag_attrs, user) - - passport_rules = %{community.title => %{"post.refinedtag.set" => true}} - rule_conn = simu_conn(:user, cms: passport_rules) - - variables = %{id: post.id, communityId: community.id, topic: "tech"} - rule_conn |> mutation_result(@set_refined_tag_query, variables, "setRefinedTag") - - variables = %{id: post.id, communityId: community.id, topic: "tech"} - rule_conn |> mutation_result(@unset_refined_tag_query, variables, "unsetRefinedTag") - - {:ok, found} = ORM.find(CMS.Post, post.id, preload: :tags) - - assoc_tags = found.tags |> Enum.map(& &1.id) - assert tag.id not in assoc_tags - end end describe "[mutation post community]" do diff --git a/test/groupher_server_web/mutation/cms/radar_test.exs b/test/groupher_server_web/mutation/cms/radar_test.exs index 6b8b3c4dd..43d828abb 100644 --- a/test/groupher_server_web/mutation/cms/radar_test.exs +++ b/test/groupher_server_web/mutation/cms/radar_test.exs @@ -24,7 +24,6 @@ defmodule GroupherServer.Test.Mutation.Radar do $tags: [Ids] $mentionUsers: [Ids] $linkAddr: String - $topic: String ) { createPost( title: $title @@ -35,7 +34,6 @@ defmodule GroupherServer.Test.Mutation.Radar do tags: $tags mentionUsers: $mentionUsers linkAddr: $linkAddr - topic: $topic ) { title id @@ -59,8 +57,7 @@ defmodule GroupherServer.Test.Mutation.Radar do post_attr |> Map.merge(%{ communityId: community.id, - linkAddr: "https://wanqu.co/a/7237/", - topic: "radar" + linkAddr: "https://wanqu.co/a/7237/" }) created = user_conn |> mutation_result(@create_post_query, variables, "createPost") @@ -79,8 +76,7 @@ defmodule GroupherServer.Test.Mutation.Radar do post_attr |> Map.merge(%{ communityId: community.id, - linkAddr: "https://unknown.com", - topic: "radar" + linkAddr: "https://unknown.com" }) created = user_conn |> mutation_result(@create_post_query, variables, "createPost") @@ -99,8 +95,7 @@ defmodule GroupherServer.Test.Mutation.Radar do post_attr |> Map.merge(%{ communityId: community.id, - linkAddr: "watdjfiefejife", - topic: "radar" + linkAddr: "watdjfiefejife" }) created = user_conn |> mutation_result(@create_post_query, variables, "createPost") diff --git a/test/groupher_server_web/mutation/statistics/statistics_test.exs b/test/groupher_server_web/mutation/statistics/statistics_test.exs index 8dc3d463f..479365e16 100644 --- a/test/groupher_server_web/mutation/statistics/statistics_test.exs +++ b/test/groupher_server_web/mutation/statistics/statistics_test.exs @@ -24,7 +24,6 @@ defmodule GroupherServer.Test.Mutation.Statistics do $length: Int! $communityId: ID! $tags: [Ids] - $topic: String ) { createPost( title: $title @@ -33,7 +32,6 @@ defmodule GroupherServer.Test.Mutation.Statistics do length: $length communityId: $communityId tags: $tags - topic: $topic ) { title body diff --git a/test/groupher_server_web/query/cms/cms_test.exs b/test/groupher_server_web/query/cms/cms_test.exs index fb40ae7c7..ef3daf637 100644 --- a/test/groupher_server_web/query/cms/cms_test.exs +++ b/test/groupher_server_web/query/cms/cms_test.exs @@ -306,8 +306,8 @@ defmodule GroupherServer.Test.Query.CMS.Basic do end @query """ - query($communityId: ID, $community: String, $thread: CmsThread, $topic: String, $all: Boolean ) { - partialTags(communityId: $communityId, community: $community, thread: $thread, topic: $topic, all: $all) { + query($communityId: ID, $community: String, $thread: CmsThread, $all: Boolean ) { + partialTags(communityId: $communityId, community: $community, thread: $thread, all: $all) { id title color @@ -348,11 +348,11 @@ defmodule GroupherServer.Test.Query.CMS.Basic do assert results |> Enum.any?(&(&1["id"] != to_string(tag2.id))) end - test "user can get partial tags by default index topic", ~m(guest_conn community user)a do + test "user can get partial tags by default", ~m(guest_conn community user)a do valid_attrs = mock_attrs(:tag) {:ok, _tag} = CMS.create_tag(community, :post, valid_attrs, user) - variables = %{thread: "POST", communityId: community.id, topic: "posts"} + variables = %{thread: "POST", communityId: community.id} results = guest_conn |> query_result(@query, variables, "partialTags") assert results |> length == 1 diff --git a/test/groupher_server_web/query/cms/posts_topic_test.exs b/test/groupher_server_web/query/cms/posts_topic_test.exs deleted file mode 100644 index 39eb32d4d..000000000 --- a/test/groupher_server_web/query/cms/posts_topic_test.exs +++ /dev/null @@ -1,125 +0,0 @@ -defmodule GroupherServer.Test.Query.PostsTopic do - use GroupherServer.TestTools - - alias GroupherServer.CMS - - setup do - {:ok, user} = db_insert(:user) - {:ok, community} = db_insert(:community) - post_attrs = mock_attrs(:post, %{community_id: community.id, topic: "posts"}) - {:ok, _post} = CMS.create_content(community, :post, post_attrs, user) - post_attrs = mock_attrs(:post, %{community_id: community.id, topic: "posts"}) - {:ok, _post} = CMS.create_content(community, :post, post_attrs, user) - - guest_conn = simu_conn(:guest) - - {:ok, ~m(guest_conn user community)a} - end - - describe "[query posts topic filter]" do - @create_post_query """ - mutation( - $title: String! - $body: String! - $digest: String! - $length: Int! - $communityId: ID! - $tags: [Ids] - $topic: String - ) { - createPost( - title: $title - body: $body - digest: $digest - length: $length - communityId: $communityId - tags: $tags - topic: $topic - ) { - title - body - id - } - } - """ - @query """ - query($filter: PagedPostsFilter!) { - pagedPosts(filter: $filter) { - entries { - id - title - } - totalCount - } - } - """ - test "create post with valid args and topic ", ~m(guest_conn)a do - {:ok, user} = db_insert(:user) - user_conn = simu_conn(:user, user) - - {:ok, community} = db_insert(:community) - post_attr = mock_attrs(:post) - - variables = post_attr |> Map.merge(%{communityId: community.id, topic: "city"}) - _created = user_conn |> mutation_result(@create_post_query, variables, "createPost") - - variables = %{filter: %{page: 1, size: 10, topic: "city"}} - results = guest_conn |> query_result(@query, variables, "pagedPosts") - - assert results["totalCount"] == 1 - end - - @query """ - query($filter: PagedPostsFilter!) { - pagedPosts(filter: $filter) { - entries { - id - title - } - totalCount - } - } - """ - test "topic filter on posts should work", ~m(guest_conn)a do - variables = %{filter: %{page: 1, size: 10}} - results = guest_conn |> query_result(@query, variables, "pagedPosts") - assert results["totalCount"] == 2 - - variables = %{filter: %{page: 1, size: 10, topic: "posts"}} - results = guest_conn |> query_result(@query, variables, "pagedPosts") - assert results["totalCount"] == 2 - - variables = %{filter: %{page: 1, size: 10, topic: "other"}} - results = guest_conn |> query_result(@query, variables, "pagedPosts") - assert results["totalCount"] == 0 - end - end - - describe "[query non-posts topic filter]" do - @query """ - query($filter: PagedJobsFilter!) { - pagedJobs(filter: $filter) { - entries { - id - title - } - totalCount - } - } - """ - test "topic filter on non-posts has no effect", ~m(guest_conn user community)a do - job_attrs = mock_attrs(:job, %{community_id: community.id, topic: "posts"}) - {:ok, _} = CMS.create_content(community, :job, job_attrs, user) - - job_attrs = mock_attrs(:job, %{community_id: community.id, topic: "city"}) - {:ok, _} = CMS.create_content(community, :job, job_attrs, user) - - variables = %{filter: %{community: community.raw, page: 1, size: 10}} - results = guest_conn |> query_result(@query, variables, "pagedJobs") - assert results["totalCount"] == 2 - - variables = %{filter: %{page: 1, size: 10, topic: "posts"}} - assert guest_conn |> query_get_error?(@query, variables) - end - end -end From 88573caec13ab74cd80f75f3ad1a959686b937db Mon Sep 17 00:00:00 2001 From: mydearxym Date: Tue, 27 Apr 2021 15:26:59 +0800 Subject: [PATCH 4/5] chore: wip --- .../cms/delegates/article_curd.ex | 4 +-- .../resolvers/cms_resolver.ex | 30 +++++++++++-------- .../cms/article_comment_replies_test.exs | 2 +- .../cms/article_comment_test.exs | 5 ++-- test/groupher_server/cms/content_pin_test.exs | 6 ++-- .../mutation/cms/cms_test.exs | 1 + .../mutation/cms/post_flag_test.exs | 2 +- .../mutation/cms/repo_test.exs | 2 +- .../query/cms/article_comment_test.exs | 2 +- .../query/cms/paged_posts_test.exs | 21 +------------ .../query/cms/posts_flags_test.exs | 4 +-- 11 files changed, 32 insertions(+), 47 deletions(-) diff --git a/lib/groupher_server/cms/delegates/article_curd.ex b/lib/groupher_server/cms/delegates/article_curd.ex index c86bdb8a1..7a18a0ae8 100644 --- a/lib/groupher_server/cms/delegates/article_curd.ex +++ b/lib/groupher_server/cms/delegates/article_curd.ex @@ -292,8 +292,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do CMS.PinedPost |> join(:inner, [p], c in assoc(p, :community)) |> join(:inner, [p], content in assoc(p, :post)) - |> where([p, c, t, content], c.raw == ^community) - |> select([p, c, t, content], content) + |> where([p, c, content], c.raw == ^community) + |> select([p, c, content], content) # 10 pined contents per community/thread, at most |> ORM.paginater(%{page: 1, size: 10}) |> done() diff --git a/lib/groupher_server_web/resolvers/cms_resolver.ex b/lib/groupher_server_web/resolvers/cms_resolver.ex index d1b8d5304..a66c304d2 100644 --- a/lib/groupher_server_web/resolvers/cms_resolver.ex +++ b/lib/groupher_server_web/resolvers/cms_resolver.ex @@ -99,27 +99,29 @@ defmodule GroupherServerWeb.Resolvers.CMS do # ####################### # content flag .. # ####################### + def pin_content(_root, ~m(id community_id thread)a, _info) do + do_pin_content(id, community_id, thread) + end + def pin_content(_root, ~m(id community_id)a, _info) do CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}) end - def pin_content(_root, ~m(id community_id thread)a, _info) do - do_pin_content(id, community_id, thread) + def undo_pin_content(_root, ~m(id community_id thread)a, _info) do + do_undo_pin_content(id, community_id, thread) end def undo_pin_content(_root, ~m(id community_id)a, _info) do CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}) end - def undo_pin_content(_root, ~m(id community_id thread)a, _info) do - do_undo_pin_content(id, community_id, thread) + def do_pin_content(id, community_id, :job) do + CMS.pin_content(%CMS.Job{id: id}, %Community{id: community_id}) end - def do_pin_content(id, community_id, :job), - do: CMS.pin_content(%CMS.Job{id: id}, %Community{id: community_id}) - - def do_pin_content(id, community_id, :repo), - do: CMS.pin_content(%CMS.Repo{id: id}, %Community{id: community_id}) + def do_pin_content(id, community_id, :repo) do + CMS.pin_content(%CMS.Repo{id: id}, %Community{id: community_id}) + end def do_undo_pin_content(id, community_id, :job) do CMS.undo_pin_content(%CMS.Job{id: id}, %Community{id: community_id}) @@ -129,11 +131,13 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.undo_pin_content(%CMS.Repo{id: id}, %Community{id: community_id}) end - def trash_content(_root, ~m(id thread community_id)a, _info), - do: set_community_flags(community_id, thread, id, %{trash: true}) + def trash_content(_root, ~m(id thread community_id)a, _info) do + set_community_flags(community_id, thread, id, %{trash: true}) + end - def undo_trash_content(_root, ~m(id thread community_id)a, _info), - do: set_community_flags(community_id, thread, id, %{trash: false}) + def undo_trash_content(_root, ~m(id thread community_id)a, _info) do + set_community_flags(community_id, thread, id, %{trash: false}) + end # TODO: report contents # def report_content(_root, ~m(id thread community_id)a, _info), diff --git a/test/groupher_server/cms/article_comment_replies_test.exs b/test/groupher_server/cms/article_comment_replies_test.exs index c54bca2e2..13cddc12e 100644 --- a/test/groupher_server/cms/article_comment_replies_test.exs +++ b/test/groupher_server/cms/article_comment_replies_test.exs @@ -100,7 +100,7 @@ defmodule GroupherServer.Test.CMS.ArticleCommentReplies do {:ok, replyed_comment_2} = CMS.reply_article_comment(replyed_comment_1.id, "reply 2", user2) {:ok, replyed_comment_3} = CMS.reply_article_comment(replyed_comment_2.id, "reply 3", user) - {:ok, parent_comment} = ORM.find(ArticleComment, parent_comment.id) + {:ok, _parent_comment} = ORM.find(ArticleComment, parent_comment.id) {:ok, replyed_comment_1} = ORM.find(ArticleComment, replyed_comment_1.id) {:ok, replyed_comment_2} = ORM.find(ArticleComment, replyed_comment_2.id) diff --git a/test/groupher_server/cms/article_comment_test.exs b/test/groupher_server/cms/article_comment_test.exs index 387b433e8..a0fca20c5 100644 --- a/test/groupher_server/cms/article_comment_test.exs +++ b/test/groupher_server/cms/article_comment_test.exs @@ -321,7 +321,6 @@ defmodule GroupherServer.Test.CMS.ArticleComment do @tag :wip test "can load paged comments participators of a article", ~m(user post)a do total_count = 30 - page_number = 1 page_size = 10 thread = :post @@ -332,8 +331,8 @@ defmodule GroupherServer.Test.CMS.ArticleComment do acc ++ [comment] end) - {:ok, comment} = CMS.create_article_comment(:post, post.id, "commment", user) - {:ok, comment} = CMS.create_article_comment(:post, post.id, "commment", user) + {:ok, _comment} = CMS.create_article_comment(:post, post.id, "commment", user) + {:ok, _comment} = CMS.create_article_comment(:post, post.id, "commment", user) {:ok, results} = CMS.list_article_comments_participators(thread, post.id, %{page: 1, size: page_size}) diff --git a/test/groupher_server/cms/content_pin_test.exs b/test/groupher_server/cms/content_pin_test.exs index 96f588048..1be36fb27 100644 --- a/test/groupher_server/cms/content_pin_test.exs +++ b/test/groupher_server/cms/content_pin_test.exs @@ -24,16 +24,16 @@ defmodule GroupherServer.Test.CMS.ContentsPin do describe "[cms post pin]" do test "can pin a post", ~m(community post)a do - {:ok, pined_post} = CMS.pin_content(post, community, "posts") + {:ok, pined_post} = CMS.pin_content(post, community) assert pined_post.id == post.id end test "can undo pin to a post", ~m(community post)a do - {:ok, pined_post} = CMS.pin_content(post, community, "posts") + {:ok, pined_post} = CMS.pin_content(post, community) assert pined_post.id == post.id - assert {:ok, unpined} = CMS.undo_pin_content(post, community, "posts") + assert {:ok, unpined} = CMS.undo_pin_content(post, community) assert unpined.id == post.id end end diff --git a/test/groupher_server_web/mutation/cms/cms_test.exs b/test/groupher_server_web/mutation/cms/cms_test.exs index 3928b3041..bf5580c6c 100644 --- a/test/groupher_server_web/mutation/cms/cms_test.exs +++ b/test/groupher_server_web/mutation/cms/cms_test.exs @@ -216,6 +216,7 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do assert belong_community["id"] == to_string(community.id) end + @tag :wip3 test "auth user create duplicate tag fails", ~m(community)a do variables = mock_attrs(:tag, %{communityId: community.id}) diff --git a/test/groupher_server_web/mutation/cms/post_flag_test.exs b/test/groupher_server_web/mutation/cms/post_flag_test.exs index c9b8e90fb..4f52f78a4 100644 --- a/test/groupher_server_web/mutation/cms/post_flag_test.exs +++ b/test/groupher_server_web/mutation/cms/post_flag_test.exs @@ -118,7 +118,7 @@ defmodule GroupherServer.Test.Mutation.PostFlag do passport_rules = %{community.raw => %{"post.undo_pin" => true}} rule_conn = simu_conn(:user, cms: passport_rules) - CMS.pin_content(post, community, "posts") + CMS.pin_content(post, community) updated = rule_conn |> mutation_result(@query, variables, "undoPinPost") assert updated["id"] == to_string(post.id) diff --git a/test/groupher_server_web/mutation/cms/repo_test.exs b/test/groupher_server_web/mutation/cms/repo_test.exs index a5e18fb42..1dc875e18 100644 --- a/test/groupher_server_web/mutation/cms/repo_test.exs +++ b/test/groupher_server_web/mutation/cms/repo_test.exs @@ -141,7 +141,7 @@ defmodule GroupherServer.Test.Mutation.Repo do created = user_conn |> mutation_result(@create_repo_query, variables, "createRepo") {:ok, repo} = ORM.find(CMS.Repo, created["id"]) - updated = + _updated = user_conn |> mutation_result( @update_repo_query, diff --git a/test/groupher_server_web/query/cms/article_comment_test.exs b/test/groupher_server_web/query/cms/article_comment_test.exs index 53b6d47b4..b40c65075 100644 --- a/test/groupher_server_web/query/cms/article_comment_test.exs +++ b/test/groupher_server_web/query/cms/article_comment_test.exs @@ -288,7 +288,7 @@ defmodule GroupherServer.Test.Query.ArticleComment do assert results["totalCount"] == total_count + 2 end - @tag :wip2 + @tag :wip test "guest user can get paged comment with floor it", ~m(guest_conn post user)a do total_count = 5 thread = :post diff --git a/test/groupher_server_web/query/cms/paged_posts_test.exs b/test/groupher_server_web/query/cms/paged_posts_test.exs index a9ab25893..b11c728ef 100644 --- a/test/groupher_server_web/query/cms/paged_posts_test.exs +++ b/test/groupher_server_web/query/cms/paged_posts_test.exs @@ -186,26 +186,7 @@ defmodule GroupherServer.Test.Query.PagedPosts do assert results["totalCount"] == 1 end - # test "read state false filter should work", ~m(user)a do - # user_conn = simu_conn(:user, user) - # {:ok, community} = db_insert(:community) - - # {:ok, post} = CMS.create_content(community, :post, mock_attrs(:post), user) - # {:ok, _post2} = CMS.create_content(community, :post, mock_attrs(:post), user) - # {:ok, _post3} = CMS.create_content(community, :post, mock_attrs(:post), user) - - # variables = %{filter: %{community: community.raw}} - # results = user_conn |> query_result(@query, variables, "pagedPosts") - # assert results["totalCount"] == 3 - - # {:ok, _} = CMS.read_content(:post, post.id, user) - - # variables = %{filter: %{community: community.raw, read: "FALSE"}} - # results = user_conn |> query_result(@query, variables, "pagedPosts") - - # assert results["totalCount"] == 2 - # end - + @tag :wip2 test "read state all filter should work", ~m(user)a do user_conn = simu_conn(:user, user) {:ok, community} = db_insert(:community) diff --git a/test/groupher_server_web/query/cms/posts_flags_test.exs b/test/groupher_server_web/query/cms/posts_flags_test.exs index ae453dc32..286eaae66 100644 --- a/test/groupher_server_web/query/cms/posts_flags_test.exs +++ b/test/groupher_server_web/query/cms/posts_flags_test.exs @@ -62,7 +62,7 @@ defmodule GroupherServer.Test.Query.PostsFlags do assert results["pageSize"] == @page_size assert results["totalCount"] == @total_count - {:ok, _pined_post} = CMS.pin_content(post_m, community, "posts") + {:ok, _pined_post} = CMS.pin_content(post_m, community) results = guest_conn |> query_result(@query, variables, "pagedPosts") entries_first = results["entries"] |> List.first() @@ -79,7 +79,7 @@ defmodule GroupherServer.Test.Query.PostsFlags do random_id = results["entries"] |> Enum.shuffle() |> List.first() |> Map.get("id") - {:ok, _pined_post} = CMS.pin_content(%Post{id: random_id}, community, "posts") + {:ok, _pined_post} = CMS.pin_content(%Post{id: random_id}, community) # {:ok, _} = CMS.set_community_flags(community, %Post{id: random_id}, %{pin: true}) results = guest_conn |> query_result(@query, variables, "pagedPosts") From 20b0aae69d405eb350e3a9d088cb1203c1e7f239 Mon Sep 17 00:00:00 2001 From: mydearxym Date: Tue, 27 Apr 2021 15:58:26 +0800 Subject: [PATCH 5/5] chore: wip --- .../cms/delegates/community_curd.ex | 1 - .../resolvers/cms_resolver.ex | 12 +- .../mutation/cms/cms_test.exs | 16 +-- .../mutation/cms/radar_test.exs | 106 ------------------ .../query/cms/paged_posts_test.exs | 2 +- 5 files changed, 15 insertions(+), 122 deletions(-) delete mode 100644 test/groupher_server_web/mutation/cms/radar_test.exs diff --git a/lib/groupher_server/cms/delegates/community_curd.ex b/lib/groupher_server/cms/delegates/community_curd.ex index b57249720..d5d97fbad 100644 --- a/lib/groupher_server/cms/delegates/community_curd.ex +++ b/lib/groupher_server/cms/delegates/community_curd.ex @@ -58,7 +58,6 @@ defmodule GroupherServer.CMS.Delegate.CommunityCURD do @doc """ create a Tag base on type: post / tuts ... """ - # TODO: change to create_tag(community, thread, attrs, ....) def create_tag(%Community{id: community_id}, thread, attrs, %Accounts.User{id: user_id}) do with {:ok, action} <- match_action(thread, :tag), {:ok, author} <- ensure_author_exists(%Accounts.User{id: user_id}), diff --git a/lib/groupher_server_web/resolvers/cms_resolver.ex b/lib/groupher_server_web/resolvers/cms_resolver.ex index a66c304d2..0f3beec44 100644 --- a/lib/groupher_server_web/resolvers/cms_resolver.ex +++ b/lib/groupher_server_web/resolvers/cms_resolver.ex @@ -103,16 +103,12 @@ defmodule GroupherServerWeb.Resolvers.CMS do do_pin_content(id, community_id, thread) end - def pin_content(_root, ~m(id community_id)a, _info) do - CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}) - end - def undo_pin_content(_root, ~m(id community_id thread)a, _info) do do_undo_pin_content(id, community_id, thread) end - def undo_pin_content(_root, ~m(id community_id)a, _info) do - CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}) + def do_pin_content(id, community_id, :post) do + CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}) end def do_pin_content(id, community_id, :job) do @@ -123,6 +119,10 @@ defmodule GroupherServerWeb.Resolvers.CMS do CMS.pin_content(%CMS.Repo{id: id}, %Community{id: community_id}) end + def do_undo_pin_content(id, community_id, :post) do + CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}) + end + def do_undo_pin_content(id, community_id, :job) do CMS.undo_pin_content(%CMS.Job{id: id}, %Community{id: community_id}) end diff --git a/test/groupher_server_web/mutation/cms/cms_test.exs b/test/groupher_server_web/mutation/cms/cms_test.exs index bf5580c6c..7bb9bbf83 100644 --- a/test/groupher_server_web/mutation/cms/cms_test.exs +++ b/test/groupher_server_web/mutation/cms/cms_test.exs @@ -216,17 +216,17 @@ defmodule GroupherServer.Test.Mutation.CMS.Basic do assert belong_community["id"] == to_string(community.id) end - @tag :wip3 - test "auth user create duplicate tag fails", ~m(community)a do - variables = mock_attrs(:tag, %{communityId: community.id}) + # TODO: @tag :wip2 + # test "auth user create duplicate tag fails", ~m(community)a do + # variables = mock_attrs(:tag, %{communityId: community.id}) - passport_rules = %{community.title => %{"post.tag.create" => true}} - rule_conn = simu_conn(:user, cms: passport_rules) + # passport_rules = %{community.title => %{"post.tag.create" => true}} + # rule_conn = simu_conn(:user, cms: passport_rules) - assert nil !== rule_conn |> mutation_result(@create_tag_query, variables, "createTag") + # assert nil !== rule_conn |> mutation_result(@create_tag_query, variables, "createTag") - assert rule_conn |> mutation_get_error?(@create_tag_query, variables, ecode(:changeset)) - end + # assert rule_conn |> mutation_get_error?(@create_tag_query, variables, ecode(:changeset)) + # end # TODO: server return 400 wrong status code # see https://github.com/absinthe-graphql/absinthe/issues/554 diff --git a/test/groupher_server_web/mutation/cms/radar_test.exs b/test/groupher_server_web/mutation/cms/radar_test.exs deleted file mode 100644 index 43d828abb..000000000 --- a/test/groupher_server_web/mutation/cms/radar_test.exs +++ /dev/null @@ -1,106 +0,0 @@ -defmodule GroupherServer.Test.Mutation.Radar do - use GroupherServer.TestTools - - # alias Helper.ORM - - setup do - {:ok, post} = db_insert(:post) - - guest_conn = simu_conn(:guest) - user_conn = simu_conn(:user) - owner_conn = simu_conn(:owner, post) - - {:ok, ~m(user_conn guest_conn owner_conn post)a} - end - - describe "[mutation radar posts]" do - @create_post_query """ - mutation( - $title: String! - $body: String! - $digest: String! - $length: Int! - $communityId: ID! - $tags: [Ids] - $mentionUsers: [Ids] - $linkAddr: String - ) { - createPost( - title: $title - body: $body - digest: $digest - length: $length - communityId: $communityId - tags: $tags - mentionUsers: $mentionUsers - linkAddr: $linkAddr - ) { - title - id - linkAddr - linkIcon - } - } - """ - @wanqu "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/wanqu.png" - @default_radar "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/default_radar.png" - @parse_error "https://cps-oss.oss-cn-shanghai.aliyuncs.com/icons/radar_source/url_parse_waning.png" - - test "create radar with known source will auto add link icon addr" do - {:ok, user} = db_insert(:user) - user_conn = simu_conn(:user, user) - - {:ok, community} = db_insert(:community) - post_attr = mock_attrs(:post) - - variables = - post_attr - |> Map.merge(%{ - communityId: community.id, - linkAddr: "https://wanqu.co/a/7237/" - }) - - created = user_conn |> mutation_result(@create_post_query, variables, "createPost") - assert created["linkIcon"] == @wanqu - assert created["linkAddr"] == "https://wanqu.co/a/7237/" - end - - test "create radar with unknown source will add default link icon addr" do - {:ok, user} = db_insert(:user) - user_conn = simu_conn(:user, user) - - {:ok, community} = db_insert(:community) - post_attr = mock_attrs(:post) - - variables = - post_attr - |> Map.merge(%{ - communityId: community.id, - linkAddr: "https://unknown.com" - }) - - created = user_conn |> mutation_result(@create_post_query, variables, "createPost") - assert created["linkIcon"] == @default_radar - assert created["linkAddr"] == "https://unknown.com" - end - - test "create radar with invalid link addr will add error link icon addr" do - {:ok, user} = db_insert(:user) - user_conn = simu_conn(:user, user) - - {:ok, community} = db_insert(:community) - post_attr = mock_attrs(:post) - - variables = - post_attr - |> Map.merge(%{ - communityId: community.id, - linkAddr: "watdjfiefejife" - }) - - created = user_conn |> mutation_result(@create_post_query, variables, "createPost") - assert created["linkIcon"] == @parse_error - assert created["linkAddr"] == "watdjfiefejife" - end - end -end diff --git a/test/groupher_server_web/query/cms/paged_posts_test.exs b/test/groupher_server_web/query/cms/paged_posts_test.exs index b11c728ef..448489bbb 100644 --- a/test/groupher_server_web/query/cms/paged_posts_test.exs +++ b/test/groupher_server_web/query/cms/paged_posts_test.exs @@ -186,7 +186,7 @@ defmodule GroupherServer.Test.Query.PagedPosts do assert results["totalCount"] == 1 end - @tag :wip2 + @tag :wip test "read state all filter should work", ~m(user)a do user_conn = simu_conn(:user, user) {:ok, community} = db_insert(:community)