Line data Source code
1 4 : (ns matchscore.domain.template-participant.entity
2 : (:require
3 : [schemas.domain.template-participants :as template-participant-schemas]))
4 :
5 :
6 32 : (def updatable-fields [:seed :status :confirmed-at :extra :roles :source])
7 :
8 :
9 4 : (defn make-template-participant
10 : "Creates a validated EventTemplateParticipant map."
11 : [data & [from-qualified]]
12 6 : (if from-qualified
13 0 : (template-participant-schemas/make-template-participant-record-from-qualified data)
14 9 : (template-participant-schemas/make-template-participant-record data)))
15 :
16 :
17 4 : (defn has-changes?
18 : "Returns true if any updatable field present in updates differs from existing."
19 : [existing updates]
20 2 : (not=
21 4 : (select-keys existing updatable-fields)
22 7 : (select-keys (merge existing updates) updatable-fields)))
23 :
24 :
25 4 : (defn merge-updates
26 : "Merges updatable fields from updates into existing event template participant."
27 : [existing updates]
28 7 : (merge existing (select-keys updates updatable-fields)))
|