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.

Commit9d7bd4a

Browse files
committed
refactor(user): add paged prefix on api
1 parentfa669dd commit9d7bd4a

File tree

11 files changed

+43
-39
lines changed

11 files changed

+43
-39
lines changed

‎lib/groupher_server/accounts/accounts.ex‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ defmodule GroupherServer.Accounts do
4646
# defdelegate paged_editable_communities(filter), to: Achievements
4747

4848
# publish
49-
defdelegatepublished_articles(user,thread,filter),to:Publish
49+
defdelegatepaged_published_articles(user,thread,filter),to:Publish
5050
defdelegatepublished_comments(user,thread,filter),to:Publish
51-
defdelegatepublished_article_comments(user,thread,filter),to:Publish
52-
defdelegatepublished_article_comments(user,thread),to:Publish
51+
defdelegatepaged_published_article_comments(user,thread,filter),to:Publish
52+
defdelegatepaged_published_article_comments(user,thread),to:Publish
5353
defdelegateupdate_published_states(user,thread),to:Publish
5454

5555
# fans

‎lib/groupher_server/accounts/delegates/publish.ex‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
1919
@doc"""
2020
get paged published contets of a user
2121
"""
22-
defpublished_articles(%User{id:user_id},thread,filter)do
22+
defpaged_published_articles(%User{id:user_id},thread,filter)do
2323
with{:ok,info}<-match(thread),
2424
{:ok,user}<-ORM.find(User,user_id)do
2525
do_paged_published_articles(info.model,user,filter)
@@ -54,7 +54,7 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
5454
|>done()
5555
end
5656

57-
defpublished_article_comments(%User{id:user_id},%{page:page,size:size}=filter)do
57+
defpaged_published_article_comments(%User{id:user_id},%{page:page,size:size}=filter)do
5858
with{:ok,user}<-ORM.find(User,user_id)do
5959
ArticleComment
6060
|>join(:inner,[comment],authorinassoc(comment,:author))
@@ -66,7 +66,11 @@ defmodule GroupherServer.Accounts.Delegate.Publish do
6666
end
6767
end
6868

69-
defpublished_article_comments(%User{id:user_id},thread,%{page:page,size:size}=filter)do
69+
defpaged_published_article_comments(
70+
%User{id:user_id},
71+
thread,
72+
%{page:page,size:size}=filter
73+
)do
7074
with{:ok,user}<-ORM.find(User,user_id)do
7175
thread=thread|>to_string|>String.upcase()
7276
thread_atom=thread|>String.downcase()|>String.to_atom()

‎lib/groupher_server_web/resolvers/accounts_resolver.ex‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,29 +179,29 @@ defmodule GroupherServerWeb.Resolvers.Accounts do
179179
end
180180

181181
# published contents
182-
defpublished_articles(_root,~m(login filter thread)a,_info)do
182+
defpaged_published_articles(_root,~m(login filter thread)a,_info)do
183183
with{:ok,user_id}<-Accounts.get_userid_and_cache(login)do
184-
Accounts.published_articles(%User{id:user_id},thread,filter)
184+
Accounts.paged_published_articles(%User{id:user_id},thread,filter)
185185
else
186186
_->raise_error(:not_exsit,"#{login} not found")
187187
end
188188
end
189189

190-
defpublished_articles(_root,~m(filter thread)a,%{context:%{cur_user:cur_user}})do
191-
Accounts.published_articles(cur_user,thread,filter)
190+
defpaged_published_articles(_root,~m(filter thread)a,%{context:%{cur_user:cur_user}})do
191+
Accounts.paged_published_articles(cur_user,thread,filter)
192192
end
193193

194-
defpublished_article_comments(_root,~m(login filter thread)a,_info)do
194+
defpaged_published_article_comments(_root,~m(login filter thread)a,_info)do
195195
with{:ok,user_id}<-Accounts.get_userid_and_cache(login)do
196-
Accounts.published_article_comments(%User{id:user_id},thread,filter)
196+
Accounts.paged_published_article_comments(%User{id:user_id},thread,filter)
197197
else
198198
_->raise_error(:not_exsit,"#{login} not found")
199199
end
200200
end
201201

202-
defpublished_article_comments(_root,~m(login filter)a,_info)do
202+
defpaged_published_article_comments(_root,~m(login filter)a,_info)do
203203
with{:ok,user_id}<-Accounts.get_userid_and_cache(login)do
204-
Accounts.published_article_comments(%User{id:user_id},filter)
204+
Accounts.paged_published_article_comments(%User{id:user_id},filter)
205205
else
206206
_->raise_error(:not_exsit,"#{login} not found")
207207
end

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ defmodule GroupherServerWeb.Schema.Helper.Queries do
1515
|>Enum.map(fnthread->
1616
quotedo
1717
@descunquote("paged published#{thread}s")
18-
fieldunquote(:"published_#{thread}s"),unquote(:"paged_#{thread}s")do
18+
fieldunquote(:"paged_published_#{thread}s"),unquote(:"paged_#{thread}s")do
1919
arg(:login,non_null(:string))
2020
arg(:filter,non_null(:paged_filter))
2121
arg(:thread,:thread,default_value:unquote(thread))
2222

2323
middleware(M.PageSizeProof)
24-
resolve(&R.Accounts.published_articles/3)
24+
resolve(&R.Accounts.paged_published_articles/3)
2525
end
2626
end
2727
end)

‎lib/groupher_server_web/schema/account/account_queries.ex‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ defmodule GroupherServerWeb.Schema.Account.Queries do
122122
end
123123

124124
@desc"get paged published article comments"
125-
field:published_article_comments,:paged_article_commentsdo
125+
field:paged_published_article_comments,:paged_article_commentsdo
126126
arg(:login,non_null(:string))
127127
arg(:filter,non_null(:paged_filter))
128128
arg(:thread,:thread,default_value::post)
129129

130130
middleware(M.PageSizeProof)
131-
resolve(&R.Accounts.published_article_comments/3)
131+
resolve(&R.Accounts.paged_published_article_comments/3)
132132
end
133133

134134
published_article_queries()

‎test/groupher_server/accounts/published/published_jobs_test.exs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule GroupherServer.Test.Accounts.Published.Job do
2828
end
2929

3030
test"fresh user get empty paged published jobs",~m(user)ado
31-
{:ok,results}=Accounts.published_articles(user,:job,%{page:1,size:20})
31+
{:ok,results}=Accounts.paged_published_articles(user,:job,%{page:1,size:20})
3232

3333
assertresults|>is_valid_pagination?(:raw)
3434
assertresults.total_count==0
@@ -59,7 +59,7 @@ defmodule GroupherServer.Test.Accounts.Published.Job do
5959
acc++[job]
6060
end)
6161

62-
{:ok,results}=Accounts.published_articles(user,:job,%{page:1,size:20})
62+
{:ok,results}=Accounts.paged_published_articles(user,:job,%{page:1,size:20})
6363

6464
assertresults|>is_valid_pagination?(:raw)
6565
assertresults.total_count==@publish_count*2
@@ -82,7 +82,7 @@ defmodule GroupherServer.Test.Accounts.Published.Job do
8282
end)
8383

8484
filter=%{page:1,size:20}
85-
{:ok,articles}=Accounts.published_article_comments(user,:job,filter)
85+
{:ok,articles}=Accounts.paged_published_article_comments(user,:job,filter)
8686

8787
entries=articles.entries
8888
article=entries|>List.first()

‎test/groupher_server/accounts/published/published_posts_test.exs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule GroupherServer.Test.Accounts.Published.Post do
2828
end
2929

3030
test"fresh user get empty paged published posts",~m(user)ado
31-
{:ok,results}=Accounts.published_articles(user,:post,%{page:1,size:20})
31+
{:ok,results}=Accounts.paged_published_articles(user,:post,%{page:1,size:20})
3232

3333
assertresults|>is_valid_pagination?(:raw)
3434
assertresults.total_count==0
@@ -59,7 +59,7 @@ defmodule GroupherServer.Test.Accounts.Published.Post do
5959
acc++[post]
6060
end)
6161

62-
{:ok,results}=Accounts.published_articles(user,:post,%{page:1,size:20})
62+
{:ok,results}=Accounts.paged_published_articles(user,:post,%{page:1,size:20})
6363

6464
assertresults|>is_valid_pagination?(:raw)
6565
assertresults.total_count==@publish_count*2
@@ -82,7 +82,7 @@ defmodule GroupherServer.Test.Accounts.Published.Post do
8282
end)
8383

8484
filter=%{page:1,size:20}
85-
{:ok,articles}=Accounts.published_article_comments(user,:post,filter)
85+
{:ok,articles}=Accounts.paged_published_article_comments(user,:post,filter)
8686

8787
entries=articles.entries
8888
article=entries|>List.first()

‎test/groupher_server/accounts/published/published_repos_test.exs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ defmodule GroupherServer.Test.Accounts.Published.Repo do
2828
end
2929

3030
test"fresh user get empty paged published repos",~m(user)ado
31-
{:ok,results}=Accounts.published_articles(user,:repo,%{page:1,size:20})
31+
{:ok,results}=Accounts.paged_published_articles(user,:repo,%{page:1,size:20})
3232

3333
assertresults|>is_valid_pagination?(:raw)
3434
assertresults.total_count==0
@@ -59,7 +59,7 @@ defmodule GroupherServer.Test.Accounts.Published.Repo do
5959
acc++[repo]
6060
end)
6161

62-
{:ok,results}=Accounts.published_articles(user,:repo,%{page:1,size:20})
62+
{:ok,results}=Accounts.paged_published_articles(user,:repo,%{page:1,size:20})
6363

6464
assertresults|>is_valid_pagination?(:raw)
6565
assertresults.total_count==@publish_count*2
@@ -82,7 +82,7 @@ defmodule GroupherServer.Test.Accounts.Published.Repo do
8282
end)
8383

8484
filter=%{page:1,size:20}
85-
{:ok,articles}=Accounts.published_article_comments(user,:repo,filter)
85+
{:ok,articles}=Accounts.paged_published_article_comments(user,:repo,filter)
8686

8787
entries=articles.entries
8888
article=entries|>List.first()

‎test/groupher_server_web/query/accounts/published/published_jobs_test.exs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Jobs do
1919
describe"[published jobs]"do
2020
@query"""
2121
query($login: String!, $filter: PagedFilter!) {
22-
publishedJobs(login: $login, filter: $filter) {
22+
pagedPublishedJobs(login: $login, filter: $filter) {
2323
entries {
2424
id
2525
title
@@ -42,7 +42,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Jobs do
4242
{:ok,job2}=CMS.create_article(community,:job,job_attrs,user)
4343

4444
variables=%{login:user.login,filter:%{page:1,size:20}}
45-
results=guest_conn|>query_result(@query,variables,"publishedJobs")
45+
results=guest_conn|>query_result(@query,variables,"pagedPublishedJobs")
4646

4747
assertresults["entries"]|>Enum.any?(&(&1["id"]==to_string(job.id)))
4848
assertresults["entries"]|>Enum.any?(&(&1["id"]==to_string(job2.id)))
@@ -52,7 +52,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Jobs do
5252
describe"[account published comments on job]"do
5353
@query"""
5454
query($login: String!, $thread: Thread, $filter: PagedFilter!) {
55-
publishedArticleComments(login: $login, thread: $thread, filter: $filter) {
55+
pagedPublishedArticleComments(login: $login, thread: $thread, filter: $filter) {
5656
entries {
5757
id
5858
bodyHtml
@@ -82,7 +82,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Jobs do
8282
random_comment_id=pub_comments|>Enum.random()|>Map.get(:id)|>to_string
8383

8484
variables=%{login:user.login,thread:"JOB",filter:%{page:1,size:20}}
85-
results=guest_conn|>query_result(@query,variables,"publishedArticleComments")
85+
results=guest_conn|>query_result(@query,variables,"pagedPublishedArticleComments")
8686

8787
assertresults|>is_valid_pagination?
8888
assertresults["totalCount"]==@publish_count

‎test/groupher_server_web/query/accounts/published/published_posts_test.exs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Posts do
1919
describe"[published posts]"do
2020
@query"""
2121
query($login: String!, $filter: PagedFilter!) {
22-
publishedPosts(login: $login, filter: $filter) {
22+
pagedPublishedPosts(login: $login, filter: $filter) {
2323
entries {
2424
id
2525
title
@@ -42,7 +42,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Posts do
4242
{:ok,post2}=CMS.create_article(community,:post,post_attrs,user)
4343

4444
variables=%{login:user.login,filter:%{page:1,size:20}}
45-
results=guest_conn|>query_result(@query,variables,"publishedPosts")
45+
results=guest_conn|>query_result(@query,variables,"pagedPublishedPosts")
4646

4747
assertresults["entries"]|>Enum.any?(&(&1["id"]==to_string(post.id)))
4848
assertresults["entries"]|>Enum.any?(&(&1["id"]==to_string(post2.id)))
@@ -52,7 +52,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Posts do
5252
describe"[account published comments on post]"do
5353
@query"""
5454
query($login: String!, $thread: Thread, $filter: PagedFilter!) {
55-
publishedArticleComments(login: $login, thread: $thread, filter: $filter) {
55+
pagedPublishedArticleComments(login: $login, thread: $thread, filter: $filter) {
5656
entries {
5757
id
5858
bodyHtml
@@ -82,7 +82,7 @@ defmodule GroupherServer.Test.Query.Accounts.Published.Posts do
8282
random_comment_id=pub_comments|>Enum.random()|>Map.get(:id)|>to_string
8383

8484
variables=%{login:user.login,thread:"POST",filter:%{page:1,size:20}}
85-
results=guest_conn|>query_result(@query,variables,"publishedArticleComments")
85+
results=guest_conn|>query_result(@query,variables,"pagedPublishedArticleComments")
8686

8787
assertresults|>is_valid_pagination?
8888
assertresults["totalCount"]==@publish_count

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp