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

This commit is contained in:
Adam Rutkowski 2025-12-01 09:37:41 +01:00 committed by GitHub
parent 3c9ba41cb6
commit 8a7d681c43
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 1 deletions

View File

@ -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),

View File

@ -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