Review comment: move assoc-if to utils.
This commit is contained in:
parent
6fbd63fed2
commit
ae65ba14fb
2 changed files with 16 additions and 16 deletions
|
@ -40,19 +40,6 @@
|
||||||
:db.install/_attribute :db.part/db}
|
:db.install/_attribute :db.part/db}
|
||||||
])
|
])
|
||||||
|
|
||||||
(defn assoc-if
|
|
||||||
([m k v]
|
|
||||||
(if v
|
|
||||||
(assoc m k v)
|
|
||||||
m))
|
|
||||||
([m k v & kvs]
|
|
||||||
(if kvs
|
|
||||||
(let [[kk vv & remainder] kvs]
|
|
||||||
(apply assoc-if
|
|
||||||
(assoc-if m k v)
|
|
||||||
kk vv remainder))
|
|
||||||
(assoc-if m k v))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn- place->entity [[id rows]]
|
(defn- place->entity [[id rows]]
|
||||||
(let [title (:title (first rows))
|
(let [title (:title (first rows))
|
||||||
|
@ -61,7 +48,7 @@
|
||||||
:page/guid (:guid (first rows))}
|
:page/guid (:guid (first rows))}
|
||||||
visits (keep :visit_date rows)]
|
visits (keep :visit_date rows)]
|
||||||
|
|
||||||
(assoc-if required
|
(util/assoc-if required
|
||||||
:page/title title
|
:page/title title
|
||||||
:page/visitAt visits)))
|
:page/visitAt visits)))
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,19 @@
|
||||||
[m path v]
|
[m path v]
|
||||||
(concat-in m path [v]))
|
(concat-in m path [v]))
|
||||||
|
|
||||||
|
(defn assoc-if
|
||||||
|
([m k v]
|
||||||
|
(if v
|
||||||
|
(assoc m k v)
|
||||||
|
m))
|
||||||
|
([m k v & kvs]
|
||||||
|
(if kvs
|
||||||
|
(let [[kk vv & remainder] kvs]
|
||||||
|
(apply assoc-if
|
||||||
|
(assoc-if m k v)
|
||||||
|
kk vv remainder))
|
||||||
|
(assoc-if m k v))))
|
||||||
|
|
||||||
(defmacro while-let [binding & forms]
|
(defmacro while-let [binding & forms]
|
||||||
`(loop []
|
`(loop []
|
||||||
(when-let ~binding
|
(when-let ~binding
|
||||||
|
|
Loading…
Reference in a new issue