Line data Source code
1 4 : (ns matchscore.domain.group.entity
2 : (:require
3 : [schemas.domain.groups :as group-schemas]))
4 :
5 :
6 24 : (def updatable-fields [:name :order :ruleset-id :config])
7 :
8 :
9 4 : (defn make-group
10 : "Creates a validated Group map."
11 : [data]
12 12 : (group-schemas/make-group-record data))
13 :
14 :
15 4 : (defn has-changes?
16 : "Returns true if merging updates into existing would produce a different result."
17 : [existing updates]
18 2 : (not=
19 4 : (select-keys existing updatable-fields)
20 7 : (select-keys (merge existing updates) updatable-fields)))
21 :
22 :
23 4 : (defn merge-updates
24 : "Merges updatable fields from updates into existing group."
25 : [existing updates]
26 7 : (merge existing (select-keys updates updatable-fields)))
|