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

Commit cf14d51

Browse files
committed
fix(article-comments): rename pined -> pinned
1 parent bf74d0f commit cf14d51

File tree

10 files changed

+26
-25
lines changed

10 files changed

+26
-25
lines changed

lib/groupher_server/cms/article_comment.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ defmodule GroupherServer.CMS.ArticleComment do
3333
@report_threshold_for_fold 5
3434

3535
# 每篇文章最多含有置顶评论的条数
36-
@pined_comment_limit 10
36+
@pinned_comment_limit 10
3737

3838
@doc "latest participators stores in article article_comment_participators field"
3939
def max_participator_count(), do: @max_participator_count
@@ -47,7 +47,7 @@ defmodule GroupherServer.CMS.ArticleComment do
4747
def delete_hint(), do: @delete_hint
4848

4949
def report_threshold_for_fold, do: @report_threshold_for_fold
50-
def pined_comment_limit, do: @pined_comment_limit
50+
def pinned_comment_limit, do: @pinned_comment_limit
5151

5252
@type t :: %ArticleComment{}
5353
schema "articles_comments" do

lib/groupher_server/cms/delegates/article_comment.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
2323
@delete_hint ArticleComment.delete_hint()
2424

2525
@default_comment_meta Embeds.ArticleCommentMeta.default_meta()
26-
@pined_comment_limit ArticleComment.pined_comment_limit()
26+
@pinned_comment_limit ArticleComment.pinned_comment_limit()
2727

2828
@doc """
2929
[timeline-mode] list paged article comments
@@ -248,7 +248,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleComment do
248248

249249
_ ->
250250
preloaded_pined_comments =
251-
Enum.slice(pined_comments, 0, @pined_comment_limit) |> Repo.preload(reply_to: :author)
251+
Enum.slice(pined_comments, 0, @pinned_comment_limit)
252+
|> Repo.preload(reply_to: :author)
252253

253254
entries = Enum.concat(preloaded_pined_comments, entries)
254255
pined_comment_count = length(pined_comments)

lib/groupher_server/cms/delegates/article_comment_action.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
3232

3333
@article_threads Community.article_threads()
3434
@max_parent_replies_count ArticleComment.max_parent_replies_count()
35-
@pined_comment_limit ArticleComment.pined_comment_limit()
35+
@pinned_comment_limit ArticleComment.pinned_comment_limit()
3636

3737
@spec pin_article_comment(Integer.t()) :: {:ok, ArticleComment.t()}
3838
@doc "pin a comment"
@@ -49,8 +49,8 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommentAction do
4949

5050
pined_comments_count = Repo.aggregate(count_query, :count)
5151

52-
case pined_comments_count >= @pined_comment_limit do
53-
true -> {:error, "only support #{@pined_comment_limit} pined comment for each article"}
52+
case pined_comments_count >= @pinned_comment_limit do
53+
true -> {:error, "only support #{@pinned_comment_limit} pinned comment for each article"}
5454
false -> {:ok, :pass}
5555
end
5656
end)

lib/groupher_server/cms/delegates/article_community.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCommunity do
201201

202202
def lock_article_comment(content), do: {:ok, content}
203203

204-
# check if the thread has aready enough pined articles
204+
# check if the thread has aready enough pinned articles
205205
defp check_pinned_article_count(community_id, thread) do
206206
thread_upcase = thread |> to_string |> String.upcase()
207207

lib/groupher_server/cms/delegates/article_curd.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
305305
|> join(:inner, [p], article in assoc(p, ^thread))
306306
|> where([p, c, article], c.raw == ^community)
307307
|> select([p, c, article], article)
308-
# 10 pined articles per community/thread, at most
308+
# 10 pinned articles per community/thread, at most
309309
|> ORM.find_all(%{page: 1, size: 10}) do
310310
concat_articles(pinned_articles, articles)
311311
else
@@ -334,7 +334,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCURD do
334334

335335
normal_count = non_pinned_articles |> Map.get(:total_count)
336336

337-
# remote the pined article from normal_entries (if have)
337+
# remote the pinned article from normal_entries (if have)
338338
pind_ids = pick_by(pinned_entries, :id)
339339
normal_entries = Enum.reject(normal_entries, &(&1.id in pind_ids))
340340

test/groupher_server/cms/comments/job_comment_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule GroupherServer.Test.CMS.Comments.JobComment do
1111
@delete_hint CMS.ArticleComment.delete_hint()
1212
@report_threshold_for_fold ArticleComment.report_threshold_for_fold()
1313
@default_comment_meta Embeds.ArticleCommentMeta.default_meta()
14-
@pined_comment_limit ArticleComment.pined_comment_limit()
14+
@pinned_comment_limit ArticleComment.pinned_comment_limit()
1515

1616
setup do
1717
{:ok, user} = db_insert(:user)
@@ -240,10 +240,10 @@ defmodule GroupherServer.Test.CMS.Comments.JobComment do
240240
assert {:error, _} = ArticlePinnedComment |> ORM.find_by(%{article_comment_id: comment.id})
241241
end
242242

243-
test "pined comments has a limit for each article", ~m(user job)a do
243+
test "pinned comments has a limit for each article", ~m(user job)a do
244244
{:ok, comment} = CMS.create_article_comment(:job, job.id, "commment", user)
245245

246-
Enum.reduce(0..(@pined_comment_limit - 1), [], fn _, _acc ->
246+
Enum.reduce(0..(@pinned_comment_limit - 1), [], fn _, _acc ->
247247
{:ok, _comment} = CMS.pin_article_comment(comment.id)
248248
end)
249249

@@ -374,7 +374,7 @@ defmodule GroupherServer.Test.CMS.Comments.JobComment do
374374
assert total_count == paged_comments.total_count
375375
end
376376

377-
test "paged article comments should contains pined comments at top position",
377+
test "paged article comments should contains pinned comments at top position",
378378
~m(user job)a do
379379
total_count = 20
380380
page_number = 1
@@ -401,7 +401,7 @@ defmodule GroupherServer.Test.CMS.Comments.JobComment do
401401
assert paged_comments.total_count == total_count + 2
402402
end
403403

404-
test "only page 1 have pined coments",
404+
test "only page 1 have pinned coments",
405405
~m(user job)a do
406406
total_count = 20
407407
page_number = 2
@@ -533,7 +533,7 @@ defmodule GroupherServer.Test.CMS.Comments.JobComment do
533533
assert job.article_comments_count == 4
534534
end
535535

536-
test "delete comment still delete pined record if needed", ~m(user job)a do
536+
test "delete comment still delete pinned record if needed", ~m(user job)a do
537537
total_count = 10
538538

539539
all_comments =

test/groupher_server/cms/comments/post_comment_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
1111
@delete_hint CMS.ArticleComment.delete_hint()
1212
@report_threshold_for_fold ArticleComment.report_threshold_for_fold()
1313
@default_comment_meta Embeds.ArticleCommentMeta.default_meta()
14-
@pined_comment_limit ArticleComment.pined_comment_limit()
14+
@pinned_comment_limit ArticleComment.pinned_comment_limit()
1515

1616
setup do
1717
{:ok, user} = db_insert(:user)
@@ -240,10 +240,10 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
240240
assert {:error, _} = ArticlePinnedComment |> ORM.find_by(%{article_comment_id: comment.id})
241241
end
242242

243-
test "pined comments has a limit for each article", ~m(user post)a do
243+
test "pinned comments has a limit for each article", ~m(user post)a do
244244
{:ok, comment} = CMS.create_article_comment(:post, post.id, "commment", user)
245245

246-
Enum.reduce(0..(@pined_comment_limit - 1), [], fn _, _acc ->
246+
Enum.reduce(0..(@pinned_comment_limit - 1), [], fn _, _acc ->
247247
{:ok, _comment} = CMS.pin_article_comment(comment.id)
248248
end)
249249

@@ -379,7 +379,7 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
379379
assert total_count == paged_comments.total_count
380380
end
381381

382-
test "paged article comments should contains pined comments at top position",
382+
test "paged article comments should contains pinned comments at top position",
383383
~m(user post)a do
384384
total_count = 20
385385
page_number = 1
@@ -411,7 +411,7 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
411411
assert paged_comments.total_count == total_count + 2
412412
end
413413

414-
test "only page 1 have pined coments",
414+
test "only page 1 have pinned coments",
415415
~m(user post)a do
416416
total_count = 20
417417
page_number = 2
@@ -558,7 +558,7 @@ defmodule GroupherServer.Test.CMS.Comments.PostComment do
558558
assert post.article_comments_count == 4
559559
end
560560

561-
test "delete comment still delete pined record if needed", ~m(user post)a do
561+
test "delete comment still delete pinned record if needed", ~m(user post)a do
562562
total_count = 10
563563

564564
all_comments =

test/groupher_server_web/query/cms/flags/jobs_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ defmodule GroupherServer.Test.Query.Flags.JobsFlags do
4949
}
5050
"""
5151

52-
test "if have pined jobs, the pined jobs should at the top of entries",
52+
test "if have pinned jobs, the pinned jobs should at the top of entries",
5353
~m(guest_conn community job_m)a do
5454
variables = %{filter: %{community: community.raw}}
5555
# variables = %{filter: %{}}

test/groupher_server_web/query/cms/flags/posts_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ defmodule GroupherServer.Test.Query.Flags.PostsFlags do
4949
}
5050
"""
5151

52-
test "if have pined posts, the pined posts should at the top of entries",
52+
test "if have pinned posts, the pinned posts should at the top of entries",
5353
~m(guest_conn community post_m)a do
5454
variables = %{filter: %{community: community.raw}}
5555
# variables = %{filter: %{}}

test/groupher_server_web/query/cms/flags/repos_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ defmodule GroupherServer.Test.Query.Flags.ReposFlags do
4949
}
5050
"""
5151

52-
test "if have pined repos, the pined repos should at the top of entries",
52+
test "if have pinned repos, the pinned repos should at the top of entries",
5353
~m(guest_conn community repo_m)a do
5454
variables = %{filter: %{community: community.raw}}
5555
# variables = %{filter: %{}}

0 commit comments

Comments
 (0)