feat: support exact client code match in dropdown search

When typing in the company dropdown search, check for an exact match
on client code via Datomic before falling back to Solr name search.
This allows users to quickly find clients by typing their code (e.g. NGRV).
This commit is contained in:
2026-05-23 13:24:40 -07:00
parent 3715910029
commit 5b2aba561c

View File

@@ -61,15 +61,17 @@
:name (str "All clients matching " (subs query 2))}]
raw-query
(let [code-matches (for [n (pull-many (dc/db conn) [:client/name :db/id]
(for [{:keys [id name]} (solr/query solr/impl "clients" {"query" (format "code:\"%s\"" raw-query)
"fields" "id, name"})
:let [client-id (Long/parseLong id)]
(let [exact-code-matches (for [n (pull-many (dc/db conn) [:client/name :db/id]
(for [client-id (map first (dc/q '[:find ?e
:in $ ?code
:where [?e :client/code ?code]]
(dc/db conn)
query))
:when (can-see-client? identity client-id)]
client-id))]
{:id (:db/id n)
:name (:client/name n)})]
(or (seq code-matches) (exec-search)))
(or (seq exact-code-matches) (exec-search)))
cleansed-query
(exec-search))))