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.

Commitb92905f

Browse files
committed
feat(paged-articles): support multi tags query
1 parentfa56e4d commitb92905f

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

‎lib/groupher_server_web/schema/Helper/fields.ex‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ defmodule GroupherServerWeb.Schema.Helper.Fields do
4141
field(:when,:when_enum)
4242
field(:length,:length_enum)
4343
field(:article_tag,:string)
44+
field(:article_tags,list_of(:string))
4445
field(:community,:string)
4546
end
4647
end

‎lib/helper/query_builder.ex‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ defmodule Helper.QueryBuilder do
181181
where:t.title==^tag_name
182182
)
183183

184+
{:article_tags,tag_name_list},queryable->
185+
from(
186+
qinqueryable,
187+
join:tinassoc(q,:article_tags),
188+
where:t.titlein^tag_name_list,
189+
distinct:q.id,
190+
group_by:q.id
191+
)
192+
184193
{:category,catetory_raw},queryable->
185194
from(
186195
qinqueryable,

‎test/groupher_server/accounts/reacted_articles_test.exs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ defmodule GroupherServer.Test.Accounts.ReactedContents do
1414
end
1515

1616
describe"[user upvoted articles]"do
17-
@tag:wip2
1817
test"user can get paged upvoted common articles",~m(user post job)ado
1918
{:ok,_}=CMS.upvote_article(:post,post.id,user)
2019
{:ok,_}=CMS.upvote_article(:job,job.id,user)

‎test/groupher_server_web/query/cms/paged_articles/paged_jobs_test.exs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ defmodule GroupherServer.Test.Query.PagedArticles.PagedJobs do
8686
assertexist_in?(article_tag,job["articleTags"],:string_key)
8787
end
8888

89+
@tag:wip2
90+
test"support multi-tag (article_tags) filter",~m(guest_conn user)ado
91+
{:ok,community}=db_insert(:community)
92+
job_attrs=mock_attrs(:job,%{community_id:community.id})
93+
{:ok,job}=CMS.create_article(community,:job,job_attrs,user)
94+
95+
article_tag_attrs=mock_attrs(:article_tag)
96+
97+
{:ok,article_tag}=CMS.create_article_tag(community,:job,article_tag_attrs,user)
98+
{:ok,article_tag2}=CMS.create_article_tag(community,:job,article_tag_attrs,user)
99+
{:ok,article_tag3}=CMS.create_article_tag(community,:job,article_tag_attrs,user)
100+
101+
{:ok,_}=CMS.set_article_tag(:job,job.id,article_tag.id)
102+
{:ok,_}=CMS.set_article_tag(:job,job.id,article_tag2.id)
103+
104+
variables=%{
105+
filter:%{page:1,size:10,article_tags:[article_tag.title,article_tag2.title]}
106+
}
107+
108+
results=guest_conn|>query_result(@query,variables,"pagedJobs")
109+
110+
job=results["entries"]|>List.first()
111+
assertresults["totalCount"]==1
112+
assertexist_in?(article_tag,job["articleTags"],:string_key)
113+
assertexist_in?(article_tag2,job["articleTags"],:string_key)
114+
assertnotexist_in?(article_tag3,job["articleTags"],:string_key)
115+
end
116+
89117
test"support community filter",~m(guest_conn user)ado
90118
{:ok,community}=db_insert(:community)
91119

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp