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

Commit 3e5047c

Browse files
committed
chore(works): plural issue
1 parent 823b7f3 commit 3e5047c

File tree

5 files changed

+6
-10
lines changed

5 files changed

+6
-10
lines changed

lib/groupher_server/cms/helper/macros.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
22
@moduledoc """
33
macros for define article related fields in CMS models
44
"""
5-
import Helper.Utils, only: [get_config: 2]
5+
import Helper.Utils, only: [get_config: 2, plural: 1]
66

77
alias GroupherServer.{CMS, Accounts}
88

@@ -220,7 +220,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
220220
many_to_many(
221221
:communities,
222222
Community,
223-
join_through: unquote("communities_join_#{to_string(thread)}s"),
223+
join_through: unquote("communities_join_#{plural(thread)}"),
224224
on_replace: :delete
225225
)
226226
end

lib/groupher_server/cms/models/works.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ defmodule GroupherServer.CMS.Model.Works do
1111
alias GroupherServer.CMS
1212
alias CMS.Model.Embeds
1313

14-
alias Helper.HTML
15-
1614
@timestamps_opts [type: :utc_datetime_usec]
1715

1816
@required_fields ~w(title digest)a
@@ -46,7 +44,5 @@ defmodule GroupherServer.CMS.Model.Works do
4644
changeset
4745
|> validate_length(:title, min: 3, max: 50)
4846
|> cast_embed(:emotions, with: &Embeds.ArticleEmotion.changeset/2)
49-
|> validate_length(:link_addr, min: 5, max: 400)
50-
|> HTML.safe_string(:body)
5147
end
5248
end

lib/groupher_server_web/schema/cms/mutations/works.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Works do
1212
arg(:body, non_null(:string))
1313
arg(:digest, non_null(:string))
1414
arg(:community_id, non_null(:id))
15-
arg(:link_addr, :string)
1615
arg(:thread, :thread, default_value: :works)
1716
arg(:article_tags, list_of(:id))
1817

priv/repo/migrations/20210625095226_create_works_table.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ defmodule GroupherServer.Repo.Migrations.CreateWorksTable do
2020
add(:collects_count, :integer, default: 0)
2121

2222
# comments
23-
add(:article_comments_participators_count, :integer, default: 0)
24-
add(:article_comments_count, :integer, default: 0)
25-
add(:article_comments_participators, :map)
23+
add(:comments_participants_count, :integer, default: 0)
24+
add(:comments_count, :integer, default: 0)
25+
add(:comments_participants, :map)
2626

2727
timestamps()
2828
end

test/groupher_server/cms/articles/works_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ defmodule GroupherServer.Test.Articles.Works do
169169
assert article_doc.body == works_doc.body
170170
end
171171

172+
@tag :wip
172173
test "delete works should also delete related document", ~m(user community works_attrs)a do
173174
{:ok, works} = CMS.create_article(community, :works, works_attrs, user)
174175
{:ok, _article_doc} = ORM.find_by(ArticleDocument, %{article_id: works.id, thread: "WORKS"})

0 commit comments

Comments
 (0)