Line data Source code
1 4 : (ns matchscore.domain.club.entity
2 : (:require
3 : [schemas.domain.club :as club-schemas]))
4 :
5 :
6 4 : (def updatable-fields
7 44 : [:name
8 : :network
9 : :country
10 : :city
11 : :phone-number
12 : :location
13 : :working-hours
14 : :images
15 : :sl-uuid
16 : :is-active])
17 :
18 :
19 4 : (defn make-club
20 : "Creates a validated Club map."
21 : [data & [from-qualified]]
22 :
23 8 : (if from-qualified
24 0 : (club-schemas/make-club-record-from-qualified data)
25 12 : (club-schemas/make-club-record data)))
26 :
27 :
28 4 : (defn has-changes?
29 : "Returns true if any updatable field present in updates differs from existing."
30 : [existing updates]
31 4 : (not=
32 8 : (select-keys existing updatable-fields)
33 14 : (select-keys (merge existing updates) updatable-fields)))
34 :
35 :
36 4 : (defn merge-updates
37 : "Merges updatable fields from updates into existing club."
38 : [existing updates]
39 14 : (merge existing (select-keys updates updatable-fields)))
|