Skip to content

Commit

Permalink
Ensure service-ids aren't duplicated, fix sync-ptv
Browse files Browse the repository at this point in the history
  • Loading branch information
Deraen authored and vharmain committed Nov 24, 2024
1 parent f66d025 commit 7ff5fd8
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions webapp/src/clj/lipas/backend/ptv/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,27 @@
(log/infof "Site type changed %s => %s, service-ids updated %s => %s"
(:previous-type-code ptv) type-code
old-service-ids new-service-ids)
(update ptv :service-ids (fn [x]
(->> x
(remove (fn [y] (contains? old-service-ids y)))
(into new-service-ids)))))
(update ptv :service-ids (fn [ids]
(let [x (set ids)
x (apply disj x old-service-ids)
x (into x new-service-ids)]
(vec x)))))
ptv)

[_ptv-resp new-ptv-data] (upsert-ptv-service-location!* tx ptv-component search user
{:org-id org-id
:ptv ptv
:site sports-site
:archive? to-archive?})]

(let [resp (core/upsert-sports-site! tx
user
(assoc sports-site
:event-date (:last-sync new-ptv-data)
:ptv new-ptv-data)
false)]
(core/index! search resp :sync))

new-ptv-data)
(catch Exception e
(let [new-ptv-data (assoc ptv :error {:message (.getMessage e)
Expand Down

0 comments on commit 7ff5fd8

Please sign in to comment.