|
172 | 172 | "Removes nil values and empty entries recursively from maps." |
173 | 173 | [m] |
174 | 174 | (walk/postwalk |
175 | | - (fn [x] |
176 | | - (cond |
177 | | - (map? x) (not-empty (into {} (filter (comp some? val)) x)) |
178 | | - (and (coll? x) (empty? x)) nil |
179 | | - :else x)) |
180 | | - m)) |
| 175 | + (fn [x] |
| 176 | + (cond |
| 177 | + (map? x) (not-empty (into {} (filter (comp some? val)) x)) |
| 178 | + (and (coll? x) (empty? x)) nil |
| 179 | + :else x)) |
| 180 | + m)) |
181 | 181 |
|
182 | 182 | (defn- make-comparable [rev] |
183 | 183 | (-> rev |
|
268 | 268 | ;; duplicates from :location :geometries and can be dereferenced |
269 | 269 | ;; using :fids |
270 | 270 | (cond-> |
271 | | - (:activities sports-site) |
| 271 | + (:activities sports-site) |
272 | 272 | (update :activities (fn [activities] |
273 | 273 | (into (empty activities) |
274 | 274 | (map (fn [[k v]] |
|
280 | 280 |
|
281 | 281 | clean)) |
282 | 282 |
|
| 283 | +(defn- ensure-route-ids |
| 284 | + "Ensure all routes in activities have an :id field" |
| 285 | + [activities] |
| 286 | + (when activities |
| 287 | + (reduce-kv |
| 288 | + (fn [acc activity-k activity-v] |
| 289 | + (if-let [routes (:routes activity-v)] |
| 290 | + (assoc-in acc [activity-k :routes] |
| 291 | + (mapv (fn [route] |
| 292 | + (if (:id route) |
| 293 | + route |
| 294 | + (assoc route :id (str (random-uuid))))) |
| 295 | + routes)) |
| 296 | + (assoc acc activity-k activity-v))) |
| 297 | + {} |
| 298 | + activities))) |
| 299 | + |
283 | 300 | (defn make-editable [sports-site] |
284 | 301 | (-> sports-site |
285 | 302 |
|
|
301 | 318 | (update-in [:locker-rooms] ->indexed-map) |
302 | 319 |
|
303 | 320 | ;; Audits |
304 | | - (update-in [:audits] ->indexed-map))) |
| 321 | + (update-in [:audits] ->indexed-map) |
| 322 | + |
| 323 | + ;; Activities routes |
| 324 | + (update :activities ensure-route-ids))) |
305 | 325 |
|
306 | 326 | ;; TODO used only in legacy energy consumption view |
307 | 327 | ;; Should be removed |
|
354 | 374 |
|
355 | 375 | (defn ->excel-row [headers m] |
356 | 376 | (reduce |
357 | | - (fn [res [k _]] |
358 | | - (let [v (get m k)] |
359 | | - (conj res {:value v |
360 | | - :type (if (number? v) |
361 | | - "number" |
362 | | - "string")}))) |
363 | | - [] headers)) |
| 377 | + (fn [res [k _]] |
| 378 | + (let [v (get m k)] |
| 379 | + (conj res {:value v |
| 380 | + :type (if (number? v) |
| 381 | + "number" |
| 382 | + "string")}))) |
| 383 | + [] headers)) |
364 | 384 |
|
365 | 385 | (defn ->excel-data [headers coll] |
366 | 386 | (let [header-row (->excel-row headers (into {} headers))] |
|
433 | 453 | (defn link? [x] |
434 | 454 | (and (string? x) |
435 | 455 | (or |
436 | | - (str/starts-with? x "http") |
437 | | - (str/starts-with? x "www")))) |
| 456 | + (str/starts-with? x "http") |
| 457 | + (str/starts-with? x "www")))) |
438 | 458 |
|
439 | 459 | (defn link-strict? [x] |
440 | 460 | (and (string? x) (str/starts-with? x "http"))) |
|
0 commit comments