From 37adb661fb1cb1a66a6614bbab8e3d42191d83f9 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 15 Nov 2020 21:00:05 -0500 Subject: [PATCH] display bans in sorted order (fixes philomena-dev/philomena#66) --- lib/philomena_web/controllers/fingerprint_profile_controller.ex | 1 + lib/philomena_web/controllers/ip_profile_controller.ex | 1 + lib/philomena_web/controllers/profile_controller.ex | 1 + lib/philomena_web/plugs/current_ban_plug.ex | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/controllers/fingerprint_profile_controller.ex b/lib/philomena_web/controllers/fingerprint_profile_controller.ex index d73da309..5c026ee5 100644 --- a/lib/philomena_web/controllers/fingerprint_profile_controller.ex +++ b/lib/philomena_web/controllers/fingerprint_profile_controller.ex @@ -19,6 +19,7 @@ defmodule PhilomenaWeb.FingerprintProfileController do fp_bans = Fingerprint |> where(fingerprint: ^fingerprint) + |> order_by(desc: :created_at) |> Repo.all() render(conn, "show.html", diff --git a/lib/philomena_web/controllers/ip_profile_controller.ex b/lib/philomena_web/controllers/ip_profile_controller.ex index 4d9ded0c..c4909fae 100644 --- a/lib/philomena_web/controllers/ip_profile_controller.ex +++ b/lib/philomena_web/controllers/ip_profile_controller.ex @@ -21,6 +21,7 @@ defmodule PhilomenaWeb.IpProfileController do subnet_bans = Subnet |> where([s], fragment("? >>= ?", s.specification, ^ip)) + |> order_by(desc: :created_at) |> Repo.all() render(conn, "show.html", diff --git a/lib/philomena_web/controllers/profile_controller.ex b/lib/philomena_web/controllers/profile_controller.ex index a141c1bc..0715e2b7 100644 --- a/lib/philomena_web/controllers/profile_controller.ex +++ b/lib/philomena_web/controllers/profile_controller.ex @@ -157,6 +157,7 @@ defmodule PhilomenaWeb.ProfileController do bans = Bans.User |> where(user_id: ^user.id) + |> order_by(desc: :created_at) |> Repo.all() render( diff --git a/lib/philomena_web/plugs/current_ban_plug.ex b/lib/philomena_web/plugs/current_ban_plug.ex index d600e8b3..0924b858 100644 --- a/lib/philomena_web/plugs/current_ban_plug.ex +++ b/lib/philomena_web/plugs/current_ban_plug.ex @@ -24,6 +24,6 @@ defmodule PhilomenaWeb.CurrentBanPlug do ban = Bans.exists_for?(user, ip, fingerprint) - Conn.assign(conn, :current_ban, ban) + Conn.assign(conn, :current_ban, ban) end end