From f328e95f4e1d2d8b8a5d543860e60a54d69e5ed7 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Thu, 1 Aug 2019 15:34:29 +0200 Subject: [PATCH] light refactorings --- src/wanijo/instance/domain.clj | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/wanijo/instance/domain.clj b/src/wanijo/instance/domain.clj index 33fa0c5..7d2bcd0 100644 --- a/src/wanijo/instance/domain.clj +++ b/src/wanijo/instance/domain.clj @@ -14,10 +14,10 @@ ::specs/name])) (spec/def ::properties (spec/coll-of - (spec/keys :req-un [::neo4j/uuid - ::specs/created_at - ::specs/updated_at - ::domain-attr/attribute]))) + (spec/keys :req-un [::neo4j/uuid + ::specs/created_at + ::specs/updated_at + ::domain-attr/attribute]))) (spec/def ::target ::instance) (spec/def ::source ::instance) (spec/def ::tags @@ -119,7 +119,7 @@ ::specs/attribute_uuid])) (spec/def ::prop-tuple (spec/coll-of - (spec/tuple fn? ::prop-tuple-values))) + (spec/tuple fn? ::prop-tuple-values))) (neo4j/defquery edit-instance "MATCH (i:instance {uuid:{uuid}}) SET i.name = {name}, @@ -180,18 +180,14 @@ (neo4j/exec-query! delete {:uuid uuid})) (defn group-by-link-and-assoc-tags [uuid query direction] - (->> (neo4j/exec-query! query - {:uuid uuid}) - (group-by - (fn [{:keys [link schema] :as row}] - {:link link - direction (direction row) - :schema schema})) + (->> (neo4j/exec-query! query {:uuid uuid}) + (group-by #(hash-map :link (:link %) + :schema (:schema %) + direction (direction %))) (map (fn [[link tags]] - (assoc link - :tags - (filter some? - (map :tag tags))))) + (let [tags (map :tag tags)] + (assoc link + :tags (filter some? tags))))) (sort-by (juxt #(-> % :schema :name) #(-> % direction :name) #(-> % direction :created_at)))))