diff --git a/src/aretherecookies/handler.clj b/src/aretherecookies/handler.clj index 90ea7b7..08b4002 100644 --- a/src/aretherecookies/handler.clj +++ b/src/aretherecookies/handler.clj @@ -56,13 +56,17 @@ (if (instance? java.util.UUID value) (.toString value) value)) (defn get-coords [item] - (get (json/read-str (get item :location)) "coordinates")) + (-> item (get :location) json/read-str (get "coordinates"))) (defn build-lat-lng [[lng lat]] (hash-map :longitude lng :latitude lat)) -(defn parse-location [item] - (dissoc (merge item (build-lat-lng (get-coords item))) :location)) +(defn build-latlng [item] + (let [[lng lat] (get-coords item)] + (hash-map :longitude lng :latitude lat))) + +(defn parse-location [item] + (-> item build-latlng (merge item) (dissoc :location))) (defn food-items-to-json [response] (map parse-location response))