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.

Commit94f72cf

Browse files
authored
chore(comments): article comments naming (#412)
* refactor(naming): paged_folded_comments* refactor(naming): drop article prefix in comments action
1 parentcbc2cab commit94f72cf

File tree

24 files changed

+132
-131
lines changed

24 files changed

+132
-131
lines changed

‎lib/groupher_server/cms/cms.ex‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ defmodule GroupherServer.CMS do
137137
defdelegatepaged_published_comments(user,thread,filters),to:CommentCurd
138138
defdelegatepaged_published_comments(user,filters),to:CommentCurd
139139

140-
defdelegatepaged_folded_article_comments(thread,article_id,filters),to:CommentCurd
141-
defdelegatepaged_folded_article_comments(thread,article_id,filters,user),to:CommentCurd
140+
defdelegatepaged_folded_comments(thread,article_id,filters),to:CommentCurd
141+
defdelegatepaged_folded_comments(thread,article_id,filters,user),to:CommentCurd
142142

143143
defdelegatepaged_comment_replies(comment_id,filters),to:CommentCurd
144144
defdelegatepaged_comment_replies(comment_id,filters,user),to:CommentCurd
@@ -154,14 +154,14 @@ defmodule GroupherServer.CMS do
154154
defdelegateupvote_comment(comment_id,user),to:CommentAction
155155
defdelegateundo_upvote_comment(comment_id,user),to:CommentAction
156156
defdelegatereply_comment(comment_id,args,user),to:CommentAction
157-
defdelegatelock_article_comment(thread,article_id),to:CommentAction
158-
defdelegateundo_lock_article_comment(thread,article_id),to:CommentAction
157+
defdelegatelock_article_comments(thread,article_id),to:CommentAction
158+
defdelegateundo_lock_article_comments(thread,article_id),to:CommentAction
159159

160160
defdelegatepin_comment(comment_id),to:CommentAction
161161
defdelegateundo_pin_comment(comment_id),to:CommentAction
162162

163-
defdelegatefold_article_comment(comment_id,user),to:CommentAction
164-
defdelegateunfold_article_comment(comment_id,user),to:CommentAction
163+
defdelegatefold_comment(comment_id,user),to:CommentAction
164+
defdelegateunfold_comment(comment_id,user),to:CommentAction
165165

166166
defdelegateemotion_to_comment(comment_id,args,user),to:CommentEmotion
167167
defdelegateundo_emotion_to_comment(comment_id,args,user),to:CommentEmotion
@@ -172,12 +172,12 @@ defmodule GroupherServer.CMS do
172172

173173
# TODO: move report to abuse report module
174174
defdelegatereport_article(thread,article_id,reason,attr,user),to:AbuseReport
175-
defdelegatereport_article_comment(comment_id,reason,attr,user),to:AbuseReport
175+
defdelegatereport_comment(comment_id,reason,attr,user),to:AbuseReport
176176
defdelegatereport_account(account_id,reason,attr,user),to:AbuseReport
177177
defdelegateundo_report_account(account_id,user),to:AbuseReport
178178
defdelegateundo_report_article(thread,article_id,user),to:AbuseReport
179179
defdelegatepaged_reports(filter),to:AbuseReport
180-
defdelegateundo_report_article_comment(comment_id,user),to:AbuseReport
180+
defdelegateundo_report_comment(comment_id,user),to:AbuseReport
181181

182182
# Passport CURD
183183
defdelegatestamp_passport(rules,user),to:PassportCURD

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
172172
end
173173

174174
@doc"report a comment"
175-
defreport_article_comment(comment_id,reason,attr,%User{}=user)do
175+
defreport_comment(comment_id,reason,attr,%User{}=user)do
176176
with{:ok,comment}<-ORM.find(Comment,comment_id)do
177177
Multi.new()
178178
|>Multi.run(:create_abuse_report,fn_,_->
@@ -184,15 +184,15 @@ defmodule GroupherServer.CMS.Delegate.AbuseReport do
184184
end)
185185
|>Multi.run(:fold_comment_report_too_many,fn_,%{create_abuse_report:abuse_report}->
186186
ifabuse_report.report_cases_count>=@report_threshold_for_fold,
187-
do:CMS.fold_article_comment(comment,user),
187+
do:CMS.fold_comment(comment,user),
188188
else:{:ok,comment}
189189
end)
190190
|>Repo.transaction()
191191
|>result()
192192
end
193193
end
194194

195-
defundo_report_article_comment(comment_id,%User{}=user)do
195+
defundo_report_comment(comment_id,%User{}=user)do
196196
undo_report_article(:comment,comment_id,user)
197197
end
198198

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,19 @@ defmodule GroupherServer.CMS.Delegate.CommentAction do
8181
end
8282

8383
@doc"fold a comment"
84-
deffold_article_comment(%Comment{}=comment,%User{}=_user)do
84+
deffold_comment(%Comment{}=comment,%User{}=_user)do
8585
comment|>ORM.update(%{is_folded:true})
8686
end
8787

8888
@doc"fold a comment"
89-
deffold_article_comment(comment_id,%User{}=_user)do
89+
deffold_comment(comment_id,%User{}=_user)do
9090
with{:ok,comment}<-ORM.find(Comment,comment_id)do
9191
comment|>ORM.update(%{is_folded:true})
9292
end
9393
end
9494

9595
@doc"unfold a comment"
96-
defunfold_article_comment(comment_id,%User{}=_user)do
96+
defunfold_comment(comment_id,%User{}=_user)do
9797
with{:ok,comment}<-ORM.find(Comment,comment_id)do
9898
comment|>ORM.update(%{is_folded:false})
9999
end
@@ -145,7 +145,7 @@ defmodule GroupherServer.CMS.Delegate.CommentAction do
145145
|>Repo.transaction()
146146
|>result()
147147
else
148-
false->raise_error(:article_comment_locked,"this article is forbid comment")
148+
false->raise_error(:article_comments_locked,"this article is forbid comment")
149149
{:error,error}->{:error,error}
150150
end
151151
end
@@ -228,7 +228,7 @@ defmodule GroupherServer.CMS.Delegate.CommentAction do
228228
end
229229

230230
@doc"lock comment of a article"
231-
deflock_article_comment(thread,id)do
231+
deflock_article_comments(thread,id)do
232232
with{:ok,info}<-match(thread),
233233
{:ok,article}<-ORM.find(info.model,id)do
234234
article_meta=ensure(article.meta,@default_article_meta)
@@ -239,7 +239,7 @@ defmodule GroupherServer.CMS.Delegate.CommentAction do
239239
end
240240

241241
@doc"undo lock comment of a article"
242-
defundo_lock_article_comment(thread,id)do
242+
defundo_lock_article_comments(thread,id)do
243243
with{:ok,info}<-match(thread),
244244
{:ok,article}<-ORM.find(info.model,id)do
245245
article_meta=ensure(article.meta,@default_article_meta)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ defmodule GroupherServer.CMS.Delegate.CommentCurd do
8383
|>done()
8484
end
8585

86-
defpaged_folded_article_comments(thread,article_id,filters)do
86+
defpaged_folded_comments(thread,article_id,filters)do
8787
where_query=dynamic([c],c.is_foldedandnotc.is_pinned)
8888
do_paged_comment(thread,article_id,filters,where_query,nil)
8989
end
9090

91-
defpaged_folded_article_comments(thread,article_id,filters,user)do
91+
defpaged_folded_comments(thread,article_id,filters,user)do
9292
where_query=dynamic([c],c.is_foldedandnotc.is_pinned)
9393
do_paged_comment(thread,article_id,filters,where_query,user)
9494
end
@@ -153,7 +153,7 @@ defmodule GroupherServer.CMS.Delegate.CommentCurd do
153153
|>Repo.transaction()
154154
|>result()
155155
else
156-
false->raise_error(:article_comment_locked,"this article is forbid comment")
156+
false->raise_error(:article_comments_locked,"this article is forbid comment")
157157
{:error,error}->{:error,error}
158158
end
159159
end

‎lib/groupher_server/cms/delegates/hooks/cite.ex‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule GroupherServer.CMS.Delegate.Hooks.Cite do
2020
2121
cited_type: thread or comment
2222
artiment: article or comment
23-
#cited_article_comment_id, [xxx_article]_id, [block_id, block2_id, ...],
23+
#cited_comment_id, [xxx_article]_id, [block_id, block2_id, ...],
2424
2525
注意 cited_by_type 不能命名为 cited_by_thread
2626

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ defmodule GroupherServer.CMS.Model.Comment do
3535
# 每篇文章最多含有置顶评论的条数
3636
@pinned_comment_limit10
3737

38-
@doc"latest participants stores in articlearticle_comment_participants field"
38+
@doc"latest participants stores in articlecomment_participants field"
3939
defmax_participator_count(),do:@max_participator_count
4040
@doc"latest replies stores in comment replies field, used for frontend display"
4141
defmax_parent_replies_count(),do:@max_parent_replies_count

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ defmodule GroupherServer.CMS.Model.CommentUpvote do
2121
end
2222

2323
@docfalse
24-
defchangeset(%CommentUpvote{}=article_comment_upvote,attrs)do
25-
article_comment_upvote
24+
defchangeset(%CommentUpvote{}=comment_upvote,attrs)do
25+
comment_upvote
2626
|>cast(attrs,@required_fields)
2727
|>validate_required(@required_fields)
2828
|>foreign_key_constraint(:comment_id)

‎lib/groupher_server_web/resolvers/cms_resolver.ex‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ defmodule GroupherServerWeb.Resolvers.CMS do
111111
# #######################
112112
# thread reaction ..
113113
# #######################
114-
deflock_article_comment(_root,~m(id thread)a,_info),do:CMS.lock_article_comment(thread,id)
114+
deflock_article_comments(_root,~m(id thread)a,_info),
115+
do:CMS.lock_article_comments(thread,id)
115116

116-
defundo_lock_article_comment(_root,~m(id thread)a,_info)do
117-
CMS.undo_lock_article_comment(thread,id)
117+
defundo_lock_article_comments(_root,~m(id thread)a,_info)do
118+
CMS.undo_lock_article_comments(thread,id)
118119
end
119120

120121
defsink_article(_root,~m(id thread)a,_info),do:CMS.sink_article(thread,id)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
261261
middleware(M.Authorize,:login)
262262
middleware(M.PassportLoader,source::community)
263263
middleware(M.Passport,claim:unquote("cms->c?->#{to_string(thread)}.lock_comment"))
264-
resolve(&R.CMS.lock_article_comment/3)
264+
resolve(&R.CMS.lock_article_comments/3)
265265
end
266266

267267
@descunquote("undo lock to a#{thread}")
@@ -273,7 +273,7 @@ defmodule GroupherServerWeb.Schema.Helper.Mutations do
273273
middleware(M.Authorize,:login)
274274
middleware(M.PassportLoader,source::community)
275275
middleware(M.Passport,claim:unquote("cms->c?->#{to_string(thread)}.undo_lock_comment"))
276-
resolve(&R.CMS.undo_lock_article_comment/3)
276+
resolve(&R.CMS.undo_lock_article_comments/3)
277277
end
278278
end
279279
end

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
246246
emotion_fields()
247247
end
248248

249-
object:article_comment_metado
249+
object:comment_metado
250250
field(:is_article_author_upvoted,:boolean)
251251
field(:is_reply_to_others,:boolean)
252252

@@ -263,7 +263,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
263263
field(:upvotes_count,:integer)
264264
field(:is_article_author,:boolean)
265265
field(:emotions,:comment_emotions)
266-
field(:meta,:article_comment_meta)
266+
field(:meta,:comment_meta)
267267
field(:replies_count,:integer)
268268
field(:reply_to,:comment_reply)
269269
field(:viewer_has_upvoted,:boolean)
@@ -281,7 +281,7 @@ defmodule GroupherServerWeb.Schema.CMS.Types do
281281
field(:upvotes_count,:integer)
282282
field(:emotions,:comment_emotions)
283283
field(:is_article_author,:boolean)
284-
field(:meta,:article_comment_meta)
284+
field(:meta,:comment_meta)
285285
field(:reply_to,:comment_reply)
286286
field(:replies,list_of(:comment_reply))
287287
field(:replies_count,:integer)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp