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))}] :name (str "All clients matching " (subs query 2))}]
raw-query raw-query
(let [code-matches (for [n (pull-many (dc/db conn) [:client/name :db/id] (let [exact-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) (for [client-id (map first (dc/q '[:find ?e
"fields" "id, name"}) :in $ ?code
:let [client-id (Long/parseLong id)] :where [?e :client/code ?code]]
(dc/db conn)
query))
:when (can-see-client? identity client-id)] :when (can-see-client? identity client-id)]
client-id))] client-id))]
{:id (:db/id n) {:id (:db/id n)
:name (:client/name n)})] :name (:client/name n)})]
(or (seq code-matches) (exec-search))) (or (seq exact-code-matches) (exec-search)))
cleansed-query cleansed-query
(exec-search)))) (exec-search))))