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.

Commit8575b26

Browse files
committed
refactor: clean up & add oneComment api
1 parent3243c53 commit8575b26

File tree

15 files changed

+77
-21
lines changed

15 files changed

+77
-21
lines changed

‎lib/groupher_server/cms/cms.ex‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ defmodule GroupherServer.CMS do
152152

153153
# Comment CURD
154154

155+
defdelegateone_comment(id),to:CommentCurd
156+
defdelegateone_comment(id,user),to:CommentCurd
157+
155158
defdelegateupdate_user_in_comments_participants(user),to:CommentCurd
156159
defdelegatepaged_comments(thread,article_id,filters,mode),to:CommentCurd
157160
defdelegatepaged_comments(thread,article_id,filters,mode,user),to:CommentCurd

‎lib/groupher_server/cms/delegates/comment_curd.ex‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,24 @@ defmodule GroupherServer.CMS.Delegate.CommentCurd do
3434
@archive_thresholdget_config(:article,:archive_threshold)
3535

3636
@doc"""
37-
[timeline-mode] list paged article comments
37+
get spec comment by id
3838
"""
39+
defone_comment(id),do:ORM.find(Comment,id)
3940

41+
defone_comment(id,%User{}=user)do
42+
with{:ok,comment}<-ORM.find(Comment,id)do
43+
%{entries:[comment]}
44+
|>mark_viewer_emotion_states(user)
45+
|>mark_viewer_has_upvoted(user)
46+
|>Map.get(:entries)
47+
|>List.first()
48+
|>done
49+
end
50+
end
51+
52+
@doc"""
53+
[timeline-mode] list paged article comments
54+
"""
4055
defpaged_comments(thread,article_id,filters,mode,user\\nil)
4156

4257
defpaged_comments(thread,article_id,filters,:timeline,user)do

‎lib/groupher_server_web/resolvers/cms_resolver.ex‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ defmodule GroupherServerWeb.Resolvers.CMS do
308308
# #######################
309309
# comemnts ..
310310
# #######################
311+
defone_comment(_root,~m(id)a,%{context:%{cur_user:user}})do
312+
CMS.one_comment(id,user)
313+
end
314+
315+
defone_comment(_root,~m(id)a,_)do
316+
CMS.one_comment(id)
317+
end
318+
311319
defpaged_comments(_root,~m(id thread filter mode)a,%{context:%{cur_user:user}})do
312320
casemodedo
313321
:replies->CMS.paged_comments(thread,id,filter,:replies,user)

‎lib/groupher_server_web/schema/cms/cms_queries.ex‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ defmodule GroupherServerWeb.Schema.CMS.Queries do
8787
resolve(&R.CMS.paged_article_tags/3)
8888
end
8989

90+
field:one_comment,:commentdo
91+
arg(:id,non_null(:id))
92+
93+
resolve(&R.CMS.one_comment/3)
94+
end
95+
9096
@desc"get paged article comments"
9197
field:paged_comments,:paged_commentsdo
9298
arg(:id,non_null(:id))

‎test/groupher_server/cms/article_community/blog_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Blog do
176176
assertreason|>is_error?(:mirror_article)
177177
end
178178

179-
@tag:wip
180179
test"blog can be mirror to home",~m(community blog_attrs user)ado
181180
{:ok,home_community}=db_insert(:community,%{raw:"home"})
182181

@@ -205,7 +204,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Blog do
205204
assertpaged_articles.total_count===1
206205
end
207206

208-
@tag:wip
209207
test"blog can be mirror to home with tags",~m(community blog_attrs user)ado
210208
{:ok,home_community}=db_insert(:community,%{raw:"home"})
211209

‎test/groupher_server/cms/article_community/drink_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Drink do
177177
assertreason|>is_error?(:mirror_article)
178178
end
179179

180-
@tag:wip
181180
test"drink can be mirror to home",~m(community drink_attrs user)ado
182181
{:ok,home_community}=db_insert(:community,%{raw:"home"})
183182

@@ -206,7 +205,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Drink do
206205
assertpaged_articles.total_count===1
207206
end
208207

209-
@tag:wip
210208
test"drink can be mirror to home with tags",~m(community drink_attrs user)ado
211209
{:ok,home_community}=db_insert(:community,%{raw:"home"})
212210

‎test/groupher_server/cms/article_community/guide_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Guide do
177177
assertreason|>is_error?(:mirror_article)
178178
end
179179

180-
@tag:wip
181180
test"guide can be mirror to home",~m(community guide_attrs user)ado
182181
{:ok,home_community}=db_insert(:community,%{raw:"home"})
183182

@@ -206,7 +205,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Guide do
206205
assertpaged_articles.total_count===1
207206
end
208207

209-
@tag:wip
210208
test"guide can be mirror to home with tags",~m(community guide_attrs user)ado
211209
{:ok,home_community}=db_insert(:community,%{raw:"home"})
212210

‎test/groupher_server/cms/article_community/job_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
176176
assertreason|>is_error?(:mirror_article)
177177
end
178178

179-
@tag:wip
180179
test"job can be mirror to home",~m(community job_attrs user)ado
181180
{:ok,home_community}=db_insert(:community,%{raw:"home"})
182181

@@ -205,7 +204,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Job do
205204
assertpaged_articles.total_count===1
206205
end
207206

208-
@tag:wip
209207
test"job can be mirror to home with tags",~m(community job_attrs user)ado
210208
{:ok,home_community}=db_insert(:community,%{raw:"home"})
211209

‎test/groupher_server/cms/article_community/meetup_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Meetup do
177177
assertreason|>is_error?(:mirror_article)
178178
end
179179

180-
@tag:wip
181180
test"meetup can be mirror to home",~m(community meetup_attrs user)ado
182181
{:ok,home_community}=db_insert(:community,%{raw:"home"})
183182

@@ -206,7 +205,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Meetup do
206205
assertpaged_articles.total_count===1
207206
end
208207

209-
@tag:wip
210208
test"meetup can be mirror to home with tags",~m(community meetup_attrs user)ado
211209
{:ok,home_community}=db_insert(:community,%{raw:"home"})
212210

‎test/groupher_server/cms/article_community/post_test.exs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
176176
assertreason|>is_error?(:mirror_article)
177177
end
178178

179-
@tag:wip
180179
test"post can be mirror to home",~m(community post_attrs user)ado
181180
{:ok,home_community}=db_insert(:community,%{raw:"home"})
182181

@@ -205,7 +204,6 @@ defmodule GroupherServer.Test.CMS.ArticleCommunity.Post do
205204
assertpaged_articles.total_count===1
206205
end
207206

208-
@tag:wip
209207
test"post can be mirror to home with tags",~m(community post_attrs user)ado
210208
{:ok,home_community}=db_insert(:community,%{raw:"home"})
211209

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp