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

Commit 516dbdd

Browse files
committed
refactor: wip
1 parent 7091f23 commit 516dbdd

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed

lib/groupher_server/cms/delegates/article_collect.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCollect do
4040
Accounts.achieve(article.author.user, :inc, :collect)
4141
end)
4242
|> Multi.run(:inc_article_collects_count, fn _, _ ->
43-
update_article_reactions_count(info, article, :collect, :inc)
43+
update_article_reactions_count(info, article, :collects_count, :inc)
4444
end)
4545
|> Multi.run(:update_article_reaction_user_list, fn _, _ ->
4646
update_article_reaction_user_list(:collect, article, user_id, :add)
@@ -79,7 +79,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleCollect do
7979
Accounts.achieve(article.author.user, :dec, :collect)
8080
end)
8181
|> Multi.run(:inc_article_collects_count, fn _, _ ->
82-
update_article_reactions_count(info, article, :collect, :dec)
82+
update_article_reactions_count(info, article, :collects_count, :dec)
8383
end)
8484
|> Multi.run(:update_article_reaction_user_list, fn _, _ ->
8585
update_article_reaction_user_list(:collect, article, user_id, :remove)

lib/groupher_server/cms/delegates/article_upvote.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleUpvote do
3333
{:ok, article} <- ORM.find(info.model, article_id, preload: [author: :user]) do
3434
Multi.new()
3535
|> Multi.run(:inc_article_upvotes_count, fn _, _ ->
36-
update_article_reactions_count(info, article, :upvote, :inc)
36+
update_article_reactions_count(info, article, :upvotes_count, :inc)
3737
end)
3838
|> Multi.run(:update_article_reaction_user_list, fn _, _ ->
3939
update_article_reaction_user_list(:upvot, article, user_id, :add)
@@ -61,7 +61,7 @@ defmodule GroupherServer.CMS.Delegate.ArticleUpvote do
6161
{:ok, article} <- ORM.find(info.model, article_id) do
6262
Multi.new()
6363
|> Multi.run(:inc_article_upvotes_count, fn _, _ ->
64-
update_article_reactions_count(info, article, :upvote, :dec)
64+
update_article_reactions_count(info, article, :upvotes_count, :dec)
6565
end)
6666
|> Multi.run(:update_article_reaction_user_list, fn _, _ ->
6767
update_article_reaction_user_list(:upvot, article, user_id, :remove)

lib/groupher_server/cms/delegates/helper.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ defmodule GroupherServer.CMS.Delegate.Helper do
114114
def update_article_reactions_count(info, article, field, opt) do
115115
schema =
116116
case field do
117-
:upvote -> ArticleUpvote
118-
:collect -> ArticleCollect
117+
:upvotes_count -> ArticleUpvote
118+
:collects_count -> ArticleCollect
119119
end
120120

121121
count_query = from(u in schema, where: field(u, ^info.foreign_key) == ^article.id)

test/groupher_server/cms/abuse_reports/post_report_test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ defmodule GroupherServer.Test.CMS.AbuseReports.PostReport do
7979
assert user.id not in post.meta.reported_user_ids
8080
end
8181

82-
@tag :wip2
8382
test "can undo a report with other user report it too",
8483
~m(community user user2 post_attrs)a do
8584
{:ok, post} = CMS.create_content(community, :post, post_attrs, user)

test/groupher_server/cms/upvotes/job_upvote_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ defmodule GroupherServer.Test.Upvotes.JobUpvote do
2727
assert article.upvotes_count == 2
2828
end
2929

30+
@tag :wip2
3031
test "job can be undo upvote && upvotes_count should dec by 1",
3132
~m(user user2 community job_attrs)a do
3233
{:ok, job} = CMS.create_content(community, :job, job_attrs, user)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ defmodule GroupherServer.Test.Query.Flags.PostsFlags do
8989
assert results["entries"] |> Enum.any?(&(&1["id"] !== random_id))
9090
end
9191

92-
@tag :wip2
9392
test "if have trashed posts, the trashed posts should not appears in result",
9493
~m(guest_conn community)a do
9594
variables = %{filter: %{community: community.raw}}

0 commit comments

Comments
 (0)