|
287 | 287 | (doseq [b (filter #(= (:type_hierarchie %) "Service Fils") (:hierarchie s_data))] |
288 | 288 | (swap! annuaire update-in [(:service b)] |
289 | 289 | conj |
290 | | - {:service_sup_id s_id |
291 | | - :service_sup_nom (get-name-from-annuaire-id s_id)})))) |
| 290 | + {:service_sup {:id s_id :nom (get-name-from-annuaire-id s_id)}})))) |
292 | 291 |
|
293 | 292 | (defn- get-ancestor [service_sup_id] |
294 | 293 | (let [seen (atom #{})] |
295 | 294 | (loop [s_id service_sup_id] |
296 | | - (let [sup (:service_sup_id (get @annuaire s_id))] |
| 295 | + (let [sup (:id (:service_sup (get @annuaire s_id)))] |
297 | 296 | (if (or (nil? sup) |
298 | 297 | (contains? @seen s_id) |
299 | 298 | (some #{s_id} @annuaire_tops)) |
|
302 | 301 | (recur sup))))))) |
303 | 302 |
|
304 | 303 | (defn- add-service-top! [] |
305 | | - (doseq [[s_id s_data] (filter #(seq (:service_sup_id (val %))) @annuaire)] |
306 | | - (let [ancestor (get-ancestor (:service_sup_id s_data))] |
307 | | - (swap! annuaire |
308 | | - update-in |
309 | | - [s_id] |
| 304 | + (doseq [[s_id s_data] (filter #(seq (:id (:service_sup (val %)))) @annuaire)] |
| 305 | + (let [ancestor (get-ancestor (:id (:service_sup s_data)))] |
| 306 | + (swap! annuaire update-in [s_id] |
310 | 307 | conj |
311 | | - {:service_top_id ancestor |
312 | | - :service_top_nom (get-name-from-annuaire-id ancestor)})))) |
| 308 | + {:service_top {:id ancestor :nom (get-name-from-annuaire-id ancestor)}})))) |
313 | 309 |
|
314 | 310 | (defn- set-annuaire! [] |
315 | 311 | ;; First download annuaire.json |
316 | 312 | (fetch-annuaire-zip) |
317 | | - ;; Then set the @annuaire atom with a subset of annuaire.json |
318 | 313 | (->> (json/parse-string (slurp "annuaire.json") true) |
319 | 314 | :service |
320 | | - (map (fn [a] [(:id a) (select-keys a [:hierarchie :nom :sigle])])) |
| 315 | + (map (fn [a] [(:id a) a])) |
321 | 316 | (into {}) |
322 | 317 | (reset! annuaire)) |
323 | 318 | ;; Then set annuaire tops |
|
363 | 358 | ;; Add top_id and top_id_name to owners |
364 | 359 | (doseq [[k {:keys [pso_id]}] (filter #(:pso_id (val %)) @owners)] |
365 | 360 | (let [top_id (or (some #{pso_id} @annuaire_tops) |
366 | | - (:service_top_id (get @annuaire pso_id))) |
| 361 | + (:id (:service_top (get @annuaire pso_id)))) |
367 | 362 | top_id_name (:nom (get @annuaire top_id))] |
368 | 363 | (swap! owners update-in [k] |
369 | 364 | conj {:pso_top_id top_id |
|
0 commit comments