Guest User

Untitled

a guest
Sep 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. ;Gets a map of locations keyed by the locationId value
  2. (defn get-all-locations-map []
  3. (let [loaded-locations
  4. (get-all-locations)]
  5. (zipmap (map (fn [k] (:locationId k)) loaded-locations) loaded-locations)))
  6.  
  7.  
  8.  
  9. (defn save-task [task-map]
  10. (let [input-id (Integer/parseInt (:taskId task-map))
  11. id (if (= input-id -1) nil input-id)
  12. locationId (:locationId task-map)
  13. ]
  14. (ds/save! (Task. id locationId task-map))))
  15.  
  16. (defn get-all-tasks []
  17. (let [locations
  18. (get-all-locations-map)]
  19. (map
  20. (fn [k]
  21. (let [task-map (:task k)
  22. taskLocationId (:taskLocationId task-map)
  23. location (if (= nil taskLocationId) nil (get locations (Integer/parseInt taskLocationId)))]
  24. (if (= location nil)
  25. task-map
  26. (assoc
  27. task-map
  28. :taskId (ds/key-id k)
  29. :taskLat (:locationLat location)
  30. :taskLng (:locationLng location)))))
  31. (ds/query :kind Task))))
Add Comment
Please, Sign In to add comment