light refactorings

neo4j-4
Josha von Gizycki 5 years ago
parent 00ef765485
commit f328e95f4e

@ -14,10 +14,10 @@
::specs/name])) ::specs/name]))
(spec/def ::properties (spec/def ::properties
(spec/coll-of (spec/coll-of
(spec/keys :req-un [::neo4j/uuid (spec/keys :req-un [::neo4j/uuid
::specs/created_at ::specs/created_at
::specs/updated_at ::specs/updated_at
::domain-attr/attribute]))) ::domain-attr/attribute])))
(spec/def ::target ::instance) (spec/def ::target ::instance)
(spec/def ::source ::instance) (spec/def ::source ::instance)
(spec/def ::tags (spec/def ::tags
@ -119,7 +119,7 @@
::specs/attribute_uuid])) ::specs/attribute_uuid]))
(spec/def ::prop-tuple (spec/def ::prop-tuple
(spec/coll-of (spec/coll-of
(spec/tuple fn? ::prop-tuple-values))) (spec/tuple fn? ::prop-tuple-values)))
(neo4j/defquery edit-instance (neo4j/defquery edit-instance
"MATCH (i:instance {uuid:{uuid}}) "MATCH (i:instance {uuid:{uuid}})
SET i.name = {name}, SET i.name = {name},
@ -180,18 +180,14 @@
(neo4j/exec-query! delete {:uuid uuid})) (neo4j/exec-query! delete {:uuid uuid}))
(defn group-by-link-and-assoc-tags [uuid query direction] (defn group-by-link-and-assoc-tags [uuid query direction]
(->> (neo4j/exec-query! query (->> (neo4j/exec-query! query {:uuid uuid})
{:uuid uuid}) (group-by #(hash-map :link (:link %)
(group-by :schema (:schema %)
(fn [{:keys [link schema] :as row}] direction (direction %)))
{:link link
direction (direction row)
:schema schema}))
(map (fn [[link tags]] (map (fn [[link tags]]
(assoc link (let [tags (map :tag tags)]
:tags (assoc link
(filter some? :tags (filter some? tags)))))
(map :tag tags)))))
(sort-by (juxt #(-> % :schema :name) (sort-by (juxt #(-> % :schema :name)
#(-> % direction :name) #(-> % direction :name)
#(-> % direction :created_at))))) #(-> % direction :created_at)))))

Loading…
Cancel
Save