Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

CRM: allow searching sites by `domain_changed_from` (#5918)

Adam Rutkowski8a7d681c4332
diff --git a/extra/lib/plausible/customer_support/resource/site.ex b/extra/lib/plausible/customer_support/resource/site.ex
index 5320073839..fb65bd3f4f 100644
--- a/extra/lib/plausible/customer_support/resource/site.ex
+++ b/extra/lib/plausible/customer_support/resource/site.ex
@@ -36,9 +36,11 @@ defmodule Plausible.CustomerSupport.Resource.Site do
inner_join: o in assoc(t, :owners),
where:
ilike(s.domain, ^"%#{input}%") or ilike(t.name, ^"%#{input}%") or
- ilike(o.name, ^"%#{input}%") or ilike(o.email, ^"%#{input}%"),
+ ilike(o.name, ^"%#{input}%") or ilike(o.email, ^"%#{input}%") or
+ ilike(s.domain_changed_from, ^"%#{input}%"),
order_by: [
desc: fragment("?.domain = ?", s, ^input),
+ desc: fragment("?.domain_changed_from = ?", s, ^input),
desc: fragment("?.name = ?", t, ^input),
desc: fragment("?.name = ?", o, ^input),
desc: fragment("?.email = ?", o, ^input),
diff --git a/test/plausible_web/live/customer_support_test.exs b/test/plausible_web/live/customer_support_test.exs
index 5a807f9f19..4dc8528a40 100644
--- a/test/plausible_web/live/customer_support_test.exs
+++ b/test/plausible_web/live/customer_support_test.exs
@@ -170,6 +170,19 @@ defmodule PlausibleWeb.Live.CustomerSupportTest do
refute_search_result(html, "team", team1.id)
assert_search_result(html, "team", team2.id)
end
+
+ test "search sites by domain_changed_from", %{conn: conn, user: user} do
+ {:ok, site} =
+ new_site(domain: "old.example.com", owner: user)
+ |> Plausible.Site.Domain.change("new.example.net")
+
+ {:ok, lv, _html} = live(conn, @cs_index)
+
+ type_into_input(lv, "filter-text", "site:old")
+ html = render(lv)
+
+ assert_search_result(html, "site", site.id)
+ end
end
defp assert_search_result(doc, type, id) do