From: Maxim Filippov Date: Fri, 6 Dec 2019 08:17:24 +0000 (+0900) Subject: Fix incorrect report count X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=08c89fd2b89614baaf4bfce067cfec9db96f2d2c;p=akkoma Fix incorrect report count --- diff --git a/lib/pleroma/pagination.ex b/lib/pleroma/pagination.ex index 9d279fba7..183ef770e 100644 --- a/lib/pleroma/pagination.ex +++ b/lib/pleroma/pagination.ex @@ -35,7 +35,10 @@ defmodule Pleroma.Pagination 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, diff --git a/lib/pleroma/web/admin_api/views/report_view.ex b/lib/pleroma/web/admin_api/views/report_view.ex index 80ca62691..f5c6ba401 100644 --- a/lib/pleroma/web/admin_api/views/report_view.ex +++ b/lib/pleroma/web/admin_api/views/report_view.ex @@ -69,12 +69,13 @@ defmodule Pleroma.Web.AdminAPI.ReportView 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 diff --git a/test/web/admin_api/admin_api_controller_test.exs b/test/web/admin_api/admin_api_controller_test.exs index 453c290e4..2a3e49af8 100644 --- a/test/web/admin_api/admin_api_controller_test.exs +++ b/test/web/admin_api/admin_api_controller_test.exs @@ -2940,11 +2940,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest 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 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do assert note["user"]["nickname"] == admin.nickname assert note["content"] == "this is disgusting!" + assert note["created_at"] assert response["total"] == 1 end end