Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitd54319f

Browse files
authored
refactor(macros): clean up (#389)
* refactor(macros): wip* refactor(macros): clean up unused macros
1 parentaf04839 commitd54319f

File tree

5 files changed

+4
-32
lines changed

5 files changed

+4
-32
lines changed

‎lib/groupher_server/cms/helper/macros.ex‎

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ defmodule GroupherServer.CMS.Helper.Macros do
55
importHelper.Utils,only:[get_config:2]
66

77
aliasGroupherServer.{CMS,Accounts}
8-
98
aliasAccounts.Model.User
109

1110
aliasCMS.Model.{
@@ -32,7 +31,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
3231
3332
add(:post_id, references(:cms_posts, on_delete: :delete_all))
3433
add(:job_id, references(:cms_jobs, on_delete: :delete_all))
35-
add(:repo_id, references(:cms_jobs, on_delete: :delete_all))
34+
add(:repo_id, references(:cms_repos, on_delete: :delete_all))
3635
...
3736
"""
3837
defmacroarticle_belongs_to_fields()do
@@ -41,7 +40,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
4140
quotedo
4241
belongs_to(
4342
unquote(thread),
44-
Module.concat(CMS.Model,unquote(thread)|>to_string|>Recase.to_pascal()),
43+
Module.concat(CMS.Model,Recase.to_pascal(to_string(unquote(thread)))),
4544
foreign_key:unquote(:"#{thread}_id")
4645
)
4746
end
@@ -184,6 +183,7 @@ defmodule GroupherServer.CMS.Helper.Macros do
184183
"""
185184
defmacrogeneral_article_fieldsdo
186185
quotedo
186+
field(:title,:string)
187187
belongs_to(:author,Author)
188188

189189
field(:views,:integer,default:0)
@@ -207,37 +207,14 @@ defmodule GroupherServer.CMS.Helper.Macros do
207207
end
208208
end
209209

210-
@doc"""
211-
for GroupherServer.CMS.Model.Community
212-
213-
# TABLE: "communities_[article]s"
214-
add(:community_id, references(:communities, on_delete: :delete_all), null: false)
215-
add(:[article]_id, references(:cms_[article]s, on_delete: :delete_all), null: false)
216-
217-
create(unique_index(:communities_[article]s, [:community_id, :[article]_id]))
218-
"""
219-
defmacrocommunity_article_fields()do
220-
@article_threads
221-
|>Enum.map(fnthread->
222-
quotedo
223-
many_to_many(
224-
unquote(:"#{thread}s"),
225-
Module.concat(CMS.Model,unquote(thread)|>to_string|>Recase.to_pascal()),
226-
join_through:unquote("communities_#{to_string(thread)}s"),
227-
join_keys:[community_id::id]++Keyword.new([{unquote(:"#{thread}_id"),:id}])
228-
)
229-
end
230-
end)
231-
end
232-
233210
@doc"""
234211
for GroupherServer.CMS.[Article]
235212
236213
# TABLE: "communities_join_[article]s"
237214
add(:community_id, references(:communities, on_delete: :delete_all), null: false)
238215
add(:[article]_id, references(:cms_[article]s, on_delete: :delete_all), null: false)
239216
240-
create(unique_index(:communities_job_[article]s, [:community_id, :[article]_id]))
217+
create(unique_index(:communities_join_[article]s, [:community_id, :[article]_id]))
241218
"""
242219
defmacroarticle_communities_field(thread)do
243220
quotedo

‎lib/groupher_server/cms/models/community.ex‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ defmodule GroupherServer.CMS.Model.Community do
7070
# on_replace: :delete
7171
)
7272

73-
community_article_fields()
74-
#
7573
# posts_block_list ...
7674
timestamps(type::utc_datetime)
7775
end

‎lib/groupher_server/cms/models/job.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ defmodule GroupherServer.CMS.Model.Job do
1919

2020
@typet::%Job{}
2121
schema"cms_jobs"do
22-
field(:title,:string)
2322
field(:company,:string)
2423
field(:company_link,:string)
2524
field(:desc,:string)

‎lib/groupher_server/cms/models/post.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ defmodule GroupherServer.CMS.Model.Post do
2323
@typet::%Post{}
2424
schema"cms_posts"do
2525
field(:body,:string)
26-
field(:title,:string)
2726
field(:digest,:string)
2827
field(:link_addr,:string)
2928
field(:copy_right,:string)

‎lib/groupher_server/cms/models/repo.ex‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ defmodule GroupherServer.CMS.Model.Repo do
2020

2121
@typet::%Repo{}
2222
schema"cms_repos"do
23-
field(:title,:string)
2423
field(:owner_name,:string)
2524
field(:owner_url,:string)
2625
field(:repo_url,:string)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp