Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Gets a map of locations keyed by the locationId value
- (defn get-all-locations-map []
- (let [loaded-locations
- (get-all-locations)]
- (zipmap (map (fn [k] (:locationId k)) loaded-locations) loaded-locations)))
- (defn save-task [task-map]
- (let [input-id (Integer/parseInt (:taskId task-map))
- id (if (= input-id -1) nil input-id)
- locationId (:locationId task-map)
- ]
- (ds/save! (Task. id locationId task-map))))
- (defn get-all-tasks []
- (let [locations
- (get-all-locations-map)]
- (map
- (fn [k]
- (let [task-map (:task k)
- taskLocationId (:taskLocationId task-map)
- location (if (= nil taskLocationId) nil (get locations (Integer/parseInt taskLocationId)))]
- (if (= location nil)
- task-map
- (assoc
- task-map
- :taskId (ds/key-id k)
- :taskLat (:locationLat location)
- :taskLng (:locationLng location)))))
- (ds/query :kind Task))))
Add Comment
Please, Sign In to add comment