Merge branch 'fix/reports-ordering' into 'develop'

Do not reverse order of reports. We want newest ones sorted to the top.

Closes #2364

See merge request pleroma/pleroma!3225
This commit is contained in:
feld 2020-12-31 19:24:49 +00:00
commit afe9c152ab
3 changed files with 27 additions and 2 deletions

View File

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm` - **Breaking:** Changed `mix pleroma.user toggle_confirmed` to `mix pleroma.user confirm`
- Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries. - Search: When using Postgres 11+, Pleroma will use the `websearch_to_tsvector` function to parse search queries.
- Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators. - Emoji: Support the full Unicode 13.1 set of Emoji for reactions, plus regional indicators.
- Admin API: Reports now ordered by newest
### Added ### Added

View File

@ -19,8 +19,7 @@ def render("index.json", %{reports: reports}) do
reports: reports:
reports[:items] reports[:items]
|> Enum.map(&Report.extract_report_info/1) |> Enum.map(&Report.extract_report_info/1)
|> Enum.map(&render(__MODULE__, "show.json", &1)) |> Enum.map(&render(__MODULE__, "show.json", &1)),
|> Enum.reverse(),
total: reports[:total] total: reports[:total]
} }
end end

View File

@ -143,4 +143,29 @@ test "doesn't error out when the user doesn't exists" do
assert %{} = ReportView.render("show.json", Report.extract_report_info(activity)) assert %{} = ReportView.render("show.json", Report.extract_report_info(activity))
end end
test "reports are ordered newest first" do
user = insert(:user)
other_user = insert(:user)
{:ok, report1} =
CommonAPI.report(user, %{
account_id: other_user.id,
comment: "first report"
})
{:ok, report2} =
CommonAPI.report(user, %{
account_id: other_user.id,
comment: "second report"
})
%{reports: rendered} =
ReportView.render("index.json",
reports: Pleroma.Web.ActivityPub.Utils.get_reports(%{}, 1, 50)
)
assert report2.id == rendered |> Enum.at(0) |> Map.get(:id)
assert report1.id == rendered |> Enum.at(1) |> Map.get(:id)
end
end end