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