From 45b15372d4d2ad2bb4bce346b892ce95700f0e8a Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Sat, 22 Jun 2019 22:35:03 +0200 Subject: [PATCH] some refactoring --- src/wanijo/instance/domain.clj | 24 +++++++++++++++--------- src/wanijo/instance/view.clj | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/wanijo/instance/domain.clj b/src/wanijo/instance/domain.clj index 5496911..314deb4 100644 --- a/src/wanijo/instance/domain.clj +++ b/src/wanijo/instance/domain.clj @@ -101,16 +101,22 @@ ON MATCH SET p.updated_at = {now}, p.value = {value}") +(defn instance->prop-tuples [instance] + (map (fn [prop] + (let [prop-uuid (:uuid prop) + uuid (if (empty? prop-uuid) + (neo4j/uuid) + prop-uuid)] + [edit-property + {:uuid uuid + :now (neo4j/now-str) + :value (:value prop) + :instance_uuid (:uuid instance) + :attribute_uuid (-> prop :attribute :uuid)}])) + (:properties instance))) + (defn edit! [instance] - (let [prop-tuples (map #(vector edit-property - {:uuid (if (empty? (:uuid %)) - (neo4j/uuid) - (:uuid %)) - :now (neo4j/now-str) - :value (:value %) - :instance_uuid (:uuid instance) - :attribute_uuid (-> % :attribute :uuid)}) - (:properties instance))] + (let [prop-tuples (instance->prop-tuples instance)] (apply neo4j/exec-queries! (concat [[edit-instance {:uuid (:uuid instance) diff --git a/src/wanijo/instance/view.clj b/src/wanijo/instance/view.clj index 7316b1a..043a8ee 100644 --- a/src/wanijo/instance/view.clj +++ b/src/wanijo/instance/view.clj @@ -92,7 +92,7 @@ (when (seq (:tags instance)) [:section.tags [:ul - (for [tag (:tags instace)] + (for [tag (:tags instance)] [:li (:name tag)])]]) (when (seq (:properties instance)) [:section.properties