Fix incorrect report count
This commit is contained in:
parent
4453a9cb73
commit
08c89fd2b8
|
@ -35,7 +35,10 @@ def fetch_paginated(query, params, :keyset) do
|
|||
end
|
||||
|
||||
def fetch_paginated(query, %{"total" => true} = params, :offset) do
|
||||
total = Repo.aggregate(query, :count, :id)
|
||||
total =
|
||||
query
|
||||
|> Ecto.Query.exclude(:left_join)
|
||||
|> Repo.aggregate(:count, :id)
|
||||
|
||||
%{
|
||||
total: total,
|
||||
|
|
|
@ -69,12 +69,13 @@ def render("index_notes.json", %{notes: notes}) when is_list(notes) do
|
|||
|
||||
def render("index_notes.json", _), do: []
|
||||
|
||||
def render("show_note.json", %{content: content, user_id: user_id}) do
|
||||
def render("show_note.json", %{content: content, user_id: user_id, inserted_at: inserted_at}) do
|
||||
user = User.get_by_id(user_id)
|
||||
|
||||
%{
|
||||
content: content,
|
||||
user: merge_account_views(user)
|
||||
user: merge_account_views(user),
|
||||
created_at: inserted_at
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -2940,11 +2940,13 @@ test "it resend emails for two users", %{admin: admin} do
|
|||
end
|
||||
|
||||
test "it creates report note", %{admin_id: admin_id, report_id: report_id} do
|
||||
[note, _] = Repo.all(Pleroma.ReportNote)
|
||||
|
||||
assert %{
|
||||
activity_id: ^report_id,
|
||||
content: "this is disgusting!",
|
||||
user_id: ^admin_id
|
||||
} = Repo.one(Pleroma.ReportNote)
|
||||
} = note
|
||||
end
|
||||
|
||||
test "it returns reports with notes", %{admin: admin} do
|
||||
|
@ -2959,6 +2961,7 @@ test "it returns reports with notes", %{admin: admin} do
|
|||
|
||||
assert note["user"]["nickname"] == admin.nickname
|
||||
assert note["content"] == "this is disgusting!"
|
||||
assert note["created_at"]
|
||||
assert response["total"] == 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue