Fix incorrect report count
authorMaxim Filippov <colixer@gmail.com>
Fri, 6 Dec 2019 08:17:24 +0000 (17:17 +0900)
committerMaxim Filippov <colixer@gmail.com>
Fri, 6 Dec 2019 08:17:24 +0000 (17:17 +0900)
lib/pleroma/pagination.ex
lib/pleroma/web/admin_api/views/report_view.ex
test/web/admin_api/admin_api_controller_test.exs

index 9d279fba7939f12256d57cf41261f0e506fba562..183ef770e77c869ba5a8bace9c7e1eccdcfbc4ae 100644 (file)
@@ -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,
index 80ca6269155f71e842866cabb020815a24486905..f5c6ba40146851b73a82f2757c185e61e84162d0 100644 (file)
@@ -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
 
index 453c290e4cf0b4a61f9f0b61f1e1a8562ecc8e56..2a3e49af8a82c90066a5e11e46c8a7139db09025 100644 (file)
@@ -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