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

Commit 19bcc01

Browse files
committed
fix(paged): total count error after pin contents
1 parent f8fed5a commit 19bcc01

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

lib/mastani_server/cms/delegates/article_curd.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,18 @@ defmodule MastaniServer.CMS.Delegate.ArticleCURD do
382382

383383
normal_entries = normal_contents |> Map.get(:entries)
384384

385-
normal_count = normal_contents |> Map.get(:total_count)
386385
pind_count = pined_content |> Map.get(:total_count)
386+
normal_count = normal_contents |> Map.get(:total_count)
387387

388388
# remote the pined content from normal_entries (if have)
389389
pind_ids = pick_by(pind_entries, :id)
390390
normal_entries = Enum.reject(normal_entries, &(&1.id in pind_ids))
391391

392392
normal_contents
393393
|> Map.put(:entries, pind_entries ++ normal_entries)
394-
|> Map.put(:total_count, pind_count + normal_count)
394+
# those two are equals
395+
# |> Map.put(:total_count, pind_count + normal_count - pind_count)
396+
|> Map.put(:total_count, normal_count)
395397
|> done
396398
end
397399
end

test/mastani_server_web/query/cms/jobs_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule MastaniServer.Test.Query.JobsFlags do
6767
results = guest_conn |> query_result(@query, variables, "pagedJobs")
6868
entries_first = results["entries"] |> List.first()
6969

70-
assert results["totalCount"] == @total_count + 1
70+
assert results["totalCount"] == @total_count
7171
assert entries_first["id"] == to_string(job_m.id)
7272
assert entries_first["pin"] == true
7373
end

test/mastani_server_web/query/cms/posts_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ defmodule MastaniServer.Test.Query.PostsFlags do
6767
results = guest_conn |> query_result(@query, variables, "pagedPosts")
6868
entries_first = results["entries"] |> List.first()
6969

70-
assert results["totalCount"] == @total_count + 1
70+
assert results["totalCount"] == @total_count
7171
assert entries_first["id"] == to_string(post_m.id)
7272
assert entries_first["pin"] == true
7373
end

test/mastani_server_web/query/cms/repos_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ defmodule MastaniServer.Test.Query.ReposFlags do
6666
results = guest_conn |> query_result(@query, variables, "pagedRepos")
6767
entries_first = results["entries"] |> List.first()
6868

69-
assert results["totalCount"] == @total_count + 1
69+
assert results["totalCount"] == @total_count
7070
assert entries_first["id"] == to_string(repo_m.id)
7171
assert entries_first["pin"] == true
7272
end

test/mastani_server_web/query/cms/videos_flags_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ defmodule MastaniServer.Test.Query.VideosFlags do
6666
results = guest_conn |> query_result(@query, variables, "pagedVideos")
6767
entries_first = results["entries"] |> List.first()
6868

69-
assert results["totalCount"] == @total_count + 1
69+
assert results["totalCount"] == @total_count
7070
assert entries_first["id"] == to_string(video_m.id)
7171
assert entries_first["pin"] == true
7272
end

0 commit comments

Comments
 (0)