Browse Source

Fix incorrect report count

remote-follow-auth-fix
Maxim Filippov 4 years ago
parent
commit
08c89fd2b8
3 changed files with 11 additions and 4 deletions
  1. +4
    -1
      lib/pleroma/pagination.ex
  2. +3
    -2
      lib/pleroma/web/admin_api/views/report_view.ex
  3. +4
    -1
      test/web/admin_api/admin_api_controller_test.exs

+ 4
- 1
lib/pleroma/pagination.ex View 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,


+ 3
- 2
lib/pleroma/web/admin_api/views/report_view.ex View 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



+ 4
- 1
test/web/admin_api/admin_api_controller_test.exs View 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


Loading…
Cancel
Save