Print timing info for pelias requests.

This commit is contained in:
John Wiseman 2020-06-02 15:27:28 -07:00
parent a45360d806
commit 8b0b1abdb3

View File

@ -14,6 +14,9 @@
(def base-pelias-url "http://lockheed.local:4000/v1")
(defn now []
(.getTime (js/Date.)))
;; Does an HTTP GET to a pelias API url. Returns a promise that
;; resolves to the API results.
@ -30,10 +33,14 @@
(defn nearby
([config lat lon options]
(log-verbose "Performing nearby query %s %s %s" lat lon options)
(pelias-get (:url config) "nearby"
(p/let [start (now)
result (pelias-get (:url config) "nearby"
{:query (assoc options
:point.lat lat
:point.lon lon)})))
:point.lon lon)})
end (now)]
(log-info "Nearby geo query took %s ms" (- end start))
result)))
;; Performs a pelias "reverse" query. Retuns a promise that resolves
@ -42,7 +49,11 @@
(defn reverse
([config lat lon options]
(log-verbose "Performing reverse query %s %s %s" lat lon options)
(pelias-get (:url config) "reverse"
(p/let [start (now)
result (pelias-get (:url config) "reverse"
{:query (assoc options
:point.lat lat
:point.lon lon)})))
:point.lon lon)})
end (now)]
(log-info "Reverse geo query took %s ms" (- end start))
result)))