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

Commit 21dfd98

Browse files
committed
refactor(drop-topic): wip
1 parent a361b9f commit 21dfd98

File tree

18 files changed

+38
-319
lines changed

18 files changed

+38
-319
lines changed

lib/groupher_server/cms/delegates/seeds_config.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
294294
color: :grey
295295
}
296296
]
297-
|> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end)
297+
|> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end)
298298
end
299299

300300
def tags(:job) do
@@ -305,7 +305,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
305305
color: :cadetblue
306306
}
307307
])
308-
|> Enum.map(fn attr -> Map.merge(%{thread: :job, topic: "jobs"}, attr) end)
308+
|> Enum.map(fn attr -> Map.merge(%{thread: :job}, attr) end)
309309
end
310310

311311
def tags(:repo) do
@@ -343,7 +343,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
343343
color: :grey
344344
}
345345
]
346-
|> Enum.map(fn attr -> Map.merge(%{thread: :repo, topic: "repos"}, attr) end)
346+
|> Enum.map(fn attr -> Map.merge(%{thread: :repo}, attr) end)
347347
end
348348

349349
def tags(_), do: []
@@ -383,7 +383,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
383383
color: :grey
384384
}
385385
]
386-
|> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end)
386+
|> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end)
387387
end
388388

389389
# home posts
@@ -422,7 +422,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
422422
color: :grey
423423
}
424424
]
425-
|> Enum.map(fn attr -> Map.merge(%{thread: :post, topic: "posts"}, attr) end)
425+
|> Enum.map(fn attr -> Map.merge(%{thread: :post}, attr) end)
426426
end
427427

428428
def tags(:home, :tech) do
@@ -460,7 +460,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
460460
color: :grey
461461
}
462462
]
463-
|> Enum.map(fn attr -> Map.merge(%{thread: :tech, topic: "tech"}, attr) end)
463+
|> Enum.map(fn attr -> Map.merge(%{thread: :tech}, attr) end)
464464
end
465465

466466
def tags(:home, :share) do
@@ -498,7 +498,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
498498
color: :grey
499499
}
500500
]
501-
|> Enum.map(fn attr -> Map.merge(%{thread: :share, topic: "share"}, attr) end)
501+
|> Enum.map(fn attr -> Map.merge(%{thread: :share}, attr) end)
502502
end
503503

504504
def tags(:home, :radar) do
@@ -537,12 +537,12 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
537537
color: :grey
538538
}
539539
]
540-
|> Enum.map(fn attr -> Map.merge(%{thread: :radar, topic: "radar"}, attr) end)
540+
|> Enum.map(fn attr -> Map.merge(%{thread: :radar}, attr) end)
541541
end
542542

543543
def tags(:home, :city) do
544544
city_tags()
545-
|> Enum.map(fn attr -> Map.merge(%{thread: :city, topic: "city"}, attr) end)
545+
|> Enum.map(fn attr -> Map.merge(%{thread: :city}, attr) end)
546546
end
547547

548548
def tags(:home, :job) do
@@ -553,7 +553,7 @@ defmodule GroupherServer.CMS.Delegate.SeedsConfig do
553553
color: :cadetblue
554554
}
555555
])
556-
|> Enum.map(fn attr -> Map.merge(%{thread: :job, topic: "jobs"}, attr) end)
556+
|> Enum.map(fn attr -> Map.merge(%{thread: :job}, attr) end)
557557
end
558558

559559
def tags(:home, _), do: []

lib/groupher_server_web/middleware/add_source_icon.ex

Lines changed: 0 additions & 41 deletions
This file was deleted.

lib/groupher_server_web/resolvers/cms_resolver.ex

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ defmodule GroupherServerWeb.Resolvers.CMS do
9999
# #######################
100100
# content flag ..
101101
# #######################
102-
def pin_content(_root, ~m(id community_id topic)a, _info) do
103-
CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id}, topic)
102+
def pin_content(_root, ~m(id community_id)a, _info) do
103+
CMS.pin_content(%CMS.Post{id: id}, %Community{id: community_id})
104104
end
105105

106106
def pin_content(_root, ~m(id community_id thread)a, _info) do
107107
do_pin_content(id, community_id, thread)
108108
end
109109

110-
def undo_pin_content(_root, ~m(id community_id topic)a, _info) do
111-
CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id}, topic)
110+
def undo_pin_content(_root, ~m(id community_id)a, _info) do
111+
CMS.undo_pin_content(%CMS.Post{id: id}, %Community{id: community_id})
112112
end
113113

114114
def undo_pin_content(_root, ~m(id community_id thread)a, _info) do
@@ -251,10 +251,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do
251251
CMS.set_tag(thread, %Tag{id: tag_id}, id)
252252
end
253253

254-
def set_refined_tag(_root, ~m(community_id thread id topic)a, _info) do
255-
CMS.set_refined_tag(%Community{id: community_id}, thread, topic, id)
256-
end
257-
258254
def set_refined_tag(_root, ~m(community_id thread id)a, _info) do
259255
CMS.set_refined_tag(%Community{id: community_id}, thread, id)
260256
end
@@ -263,10 +259,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do
263259
CMS.unset_tag(thread, %Tag{id: tag_id}, id)
264260
end
265261

266-
def unset_refined_tag(_root, ~m(community_id thread id topic)a, _info) do
267-
CMS.unset_refined_tag(%Community{id: community_id}, thread, topic, id)
268-
end
269-
270262
def unset_refined_tag(_root, ~m(community_id thread id)a, _info) do
271263
CMS.unset_refined_tag(%Community{id: community_id}, thread, id)
272264
end
@@ -279,14 +271,6 @@ defmodule GroupherServerWeb.Resolvers.CMS do
279271
CMS.get_tags(%Community{raw: community})
280272
end
281273

282-
def get_tags(_root, ~m(community_id thread topic)a, _info) do
283-
CMS.get_tags(%Community{id: community_id}, thread, topic)
284-
end
285-
286-
def get_tags(_root, ~m(community thread topic)a, _info) do
287-
CMS.get_tags(%Community{raw: community}, thread, topic)
288-
end
289-
290274
def get_tags(_root, ~m(community_id thread)a, _info) do
291275
CMS.get_tags(%Community{id: community_id}, thread)
292276
end
@@ -295,6 +279,10 @@ defmodule GroupherServerWeb.Resolvers.CMS do
295279
CMS.get_tags(%Community{raw: community}, thread)
296280
end
297281

282+
def get_tags(_root, ~m(community_id thread)a, _info) do
283+
CMS.get_tags(%Community{id: community_id}, thread)
284+
end
285+
298286
def get_tags(_root, %{thread: _thread}, _info) do
299287
{:error, "community_id or community is needed"}
300288
end

lib/groupher_server_web/schema/cms/cms_misc.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,6 @@ defmodule GroupherServerWeb.Schema.CMS.Misc do
226226
pagination_args()
227227
article_filter_fields()
228228
field(:sort, :sort_enum)
229-
230-
field(:topic, :string)
231229
end
232230

233231
@desc "job_filter doc"

lib/groupher_server_web/schema/cms/cms_queries.ex

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
154154
arg(:community_id, :id)
155155
arg(:community, :string)
156156
arg(:thread, :cms_thread, default_value: :post)
157-
arg(:topic, :string)
158157
arg(:all, :boolean, default_value: false)
159158

160159
resolve(&R.CMS.get_tags/3)

lib/groupher_server_web/schema/cms/cms_types.ex

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
4242
field(:author, :user, resolve: dataloader(CMS, :author))
4343
field(:origial_community, :community, resolve: dataloader(CMS, :origial_community))
4444
field(:communities, list_of(:community), resolve: dataloader(CMS, :communities))
45-
# field(:topic)
4645

4746
field(:meta, :article_meta)
4847
field(:article_comments_participators, list_of(:user))
@@ -312,20 +311,13 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
312311
timestamp_fields()
313312
end
314313

315-
object :topic do
316-
field(:id, :id)
317-
field(:title, :string)
318-
field(:raw, :string)
319-
end
320-
321314
object :tag do
322315
field(:id, :id)
323316
field(:title, :string)
324317
field(:color, :string)
325318
field(:thread, :string)
326319
field(:author, :user, resolve: dataloader(CMS, :author))
327320
field(:community, :community, resolve: dataloader(CMS, :community))
328-
field(:topic, :topic, resolve: dataloader(CMS, :topic))
329321

330322
timestamp_fields()
331323
end

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Community do
132132
arg(:color, non_null(:rainbow_color_enum))
133133
arg(:community_id, non_null(:id))
134134
arg(:thread, :cms_thread, default_value: :post)
135-
arg(:topic, :string, default_value: "posts")
136135

137136
middleware(M.Authorize, :login)
138137
middleware(M.PassportLoader, source: :community)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
9898
arg(:id, non_null(:id))
9999
arg(:community_id, non_null(:id))
100100
arg(:thread, :cms_thread, default_value: :post)
101-
arg(:topic, :string)
102101

103102
middleware(M.Authorize, :login)
104103
middleware(M.PassportLoader, source: :community)
@@ -127,7 +126,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Operation do
127126
arg(:id, non_null(:id))
128127
arg(:community_id, non_null(:id))
129128
arg(:thread, :cms_thread, default_value: :post)
130-
arg(:topic, :string)
131129

132130
middleware(M.Authorize, :login)
133131
middleware(M.PassportLoader, source: :community)

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do
1515
arg(:copy_right, :string)
1616
arg(:community_id, non_null(:id))
1717
arg(:thread, :cms_thread, default_value: :post)
18-
arg(:topic, :string, default_value: "posts")
1918
arg(:tags, list_of(:ids))
2019
arg(:mention_users, list_of(:ids))
2120

2221
middleware(M.Authorize, :login)
2322
# middleware(M.PublishThrottle)
24-
middleware(M.AddSourceIcon)
2523
middleware(M.PublishThrottle, interval: 3, hour_limit: 15, day_limit: 30)
2624
resolve(&R.CMS.create_content/3)
2725
middleware(M.Statistics.MakeContribute, for: [:user, :community])
@@ -32,7 +30,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do
3230
arg(:id, non_null(:id))
3331
arg(:community_id, non_null(:id))
3432
arg(:thread, :post_thread, default_value: :post)
35-
arg(:topic, :string, default_value: "posts")
3633

3734
middleware(M.Authorize, :login)
3835
middleware(M.PassportLoader, source: :community)
@@ -45,7 +42,6 @@ defmodule GroupherServerWeb.Schema.CMS.Mutations.Post do
4542
arg(:id, non_null(:id))
4643
arg(:thread, :post_thread, default_value: :post)
4744
arg(:community_id, non_null(:id))
48-
arg(:topic, :string, default_value: "posts")
4945

5046
middleware(M.Authorize, :login)
5147
middleware(M.PassportLoader, source: :community)

lib/helper/query_builder.ex

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,6 @@ defmodule Helper.QueryBuilder do
182182
where: t.title == ^tag_name
183183
)
184184

185-
{:topic, topic}, queryable ->
186-
from(
187-
q in queryable,
188-
join: t in assoc(q, :topics),
189-
where: t.raw == ^topic
190-
)
191-
192185
{:category, catetory_raw}, queryable ->
193186
from(
194187
q in queryable,

0 commit comments

Comments
 (0)