cloud - finishes search implementation
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
is-admin?
|
||||
limited-clients
|
||||
result->page]]
|
||||
[auto-ap.search :as search]
|
||||
[auto-ap.solr :as solr]
|
||||
[datomic.api :as dc]
|
||||
[iol-ion.tx :refer [random-tempid]]
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
[iol-ion.tx :refer [random-tempid]]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler])
|
||||
[yang.scheduler :as scheduler]
|
||||
[auto-ap.solr :as solr])
|
||||
(:import
|
||||
(java.util UUID)
|
||||
(org.apache.commons.codec.binary Base64)))
|
||||
@@ -156,7 +157,15 @@
|
||||
result (audit-transact [[:upsert-entity updated-entity]] (:id context))]
|
||||
(when (:square_auth_token edit_client)
|
||||
(square/upsert-locations (-> result :tempids (get id) (or id) d-clients/get-by-id)))
|
||||
(-> (-> result :tempids (get id) (or id) d-clients/get-by-id)
|
||||
(let [updated-client (-> result :tempids (get id) (or id) d-clients/get-by-id)]
|
||||
(solr/index-documents-raw solr/impl "clients"
|
||||
[{"id" (:db/id updated-client)
|
||||
"name" (conj (or (:client/matches updated-client) [])
|
||||
(:client/name updated-client))
|
||||
"code" (:client/code updated-client)
|
||||
"exact" (map str/upper-case (conj (or (:client/matches updated-client) [])
|
||||
(:client/name updated-client)))}])
|
||||
(-> updated-client
|
||||
|
||||
(update :client/bank-accounts
|
||||
(fn [bas]
|
||||
@@ -165,11 +174,11 @@
|
||||
(fn [lms]
|
||||
(mapcat (fn [lm]
|
||||
(map (fn [m]
|
||||
{:location-match/match m
|
||||
:location-match/location (:location-match/location lm)})
|
||||
(:location-match/matches lm)))
|
||||
{:location-match/match m
|
||||
:location-match/location (:location-match/location lm)})
|
||||
(:location-match/matches lm)))
|
||||
lms)))
|
||||
->graphql)))
|
||||
->graphql))))
|
||||
|
||||
|
||||
(defn refresh-all-current-balance []
|
||||
@@ -629,8 +638,3 @@
|
||||
:input-objects input-objects
|
||||
:enums enums})
|
||||
(attach-tracing-resolvers resolvers)))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(mount/defstate indexer
|
||||
:start (scheduler/every (* 5 60 1000) (heartbeat d-clients/rebuild-search-index "rebuild-search-index"))
|
||||
:stop (scheduler/stop indexer))
|
||||
|
||||
@@ -1,35 +1,22 @@
|
||||
(ns auto-ap.graphql.ezcater
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.graphql.utils
|
||||
:refer [assert-admin attach-tracing-resolvers cleanse-query]]
|
||||
[auto-ap.search :as search]
|
||||
[auto-ap.utils :refer [heartbeat]]
|
||||
[datomic.api :as dc]
|
||||
[mount.core :as mount]
|
||||
[yang.scheduler :as scheduler]))
|
||||
[auto-ap.graphql.utils :refer [assert-admin attach-tracing-resolvers]]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]))
|
||||
|
||||
(defn search [context args _]
|
||||
(assert-admin (:id context))
|
||||
(let [search-query (cleanse-query (:query args))]
|
||||
(for [[id name] (search/search {:q search-query}
|
||||
"ezcater-caterer")]
|
||||
{:name name
|
||||
:id (Long/parseLong id)})))
|
||||
(for [[id name] (dc/q '[:find ?i ?n
|
||||
:in $ ?s
|
||||
:where [?i :ezcater-caterer/name ?n]
|
||||
[(clojure.string/upper-case ?n) ?n2]
|
||||
[(clojure.string/includes? ?n2 ?s)]]
|
||||
(dc/db conn)
|
||||
(str/upper-case (:query args)))]
|
||||
{:name name
|
||||
:id id}))
|
||||
|
||||
(defn rebuild-search-index []
|
||||
(search/full-index-query
|
||||
(for [result (map first (dc/qseq {:query '[:find (pull ?a [:ezcater-caterer/search-terms :db/id :ezcater-caterer/name])
|
||||
:in $
|
||||
:where [?a :ezcater-caterer/search-terms ]]
|
||||
:args [(dc/db conn)]}))]
|
||||
{:id (:db/id result)
|
||||
:text (:ezcater-caterer/search-terms result)})
|
||||
"ezcater-caterer"))
|
||||
|
||||
(mount/defstate indexer
|
||||
:start (scheduler/every (* 5 60 1000) (heartbeat rebuild-search-index "rebuild-search-index"))
|
||||
:stop (scheduler/stop indexer))
|
||||
|
||||
(def objects
|
||||
{:ezcater_caterer {:fields {:name {:type 'String}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
(ns auto-ap.graphql.vendors
|
||||
(:require
|
||||
[auto-ap.datomic :refer [audit-transact conn pull-attr remove-nils]]
|
||||
[iol-ion.tx :refer [random-tempid]]
|
||||
[auto-ap.datomic :refer [audit-transact conn remove-nils]]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.graphql.utils
|
||||
:refer [->graphql
|
||||
<-graphql
|
||||
@@ -13,19 +11,13 @@
|
||||
enum->keyword
|
||||
is-admin?
|
||||
result->page]]
|
||||
[auto-ap.search :as search]
|
||||
[auto-ap.utils :refer [heartbeat]]
|
||||
[auto-ap.solr :as solr]
|
||||
[clojure.set :as set]
|
||||
[clojure.string :as str]
|
||||
[manifold.executor :as ex]
|
||||
[manifold.deferred :as de]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as dc]
|
||||
[yang.scheduler :as scheduler]
|
||||
[mount.core :as mount]
|
||||
[clj-time.core :as time]
|
||||
[clj-time.coerce :as coerce]
|
||||
[com.brunobonacci.mulog :as mu]))
|
||||
[iol-ion.tx :refer [random-tempid]]
|
||||
[manifold.deferred :as de]
|
||||
[manifold.executor :as ex]))
|
||||
|
||||
(defn can-user-edit-vendor? [vendor-id id]
|
||||
(if (is-admin? id)
|
||||
|
||||
Reference in New Issue
Block a user