fix sorting

neo4j-4
Josha von Gizycki 5 years ago
parent c03a526308
commit 3e8c38ec44

@ -36,8 +36,7 @@
WHERE s.uuid = {uuid}
OPTIONAL MATCH
(i)-[:tagged_with]->(t:tag)
RETURN i, t
ORDER BY i.name")
RETURN i, t")
(defn find-by-schema! [schema-uuid]
{:post [(spec/assert ::instances-with-tags %)]}
(->> (neo4j/exec-query! findy-by-schema
@ -46,7 +45,8 @@
(map #(assoc (key %)
:tags (->> (val %)
(map :t)
(filter some?))))))
(filter some?))))
(sort-by :name)))
(neo4j/defquery create-instance
"MATCH (s:schema {uuid:{schema_uuid}}),
@ -202,7 +202,7 @@
(:to link))]
(apply neo4j/exec-queries! tuples)))
(defn grouped-links-by-tag [uuid query direction]
(defn group-by-link-and-assoc-tags [uuid query direction]
(->> (neo4j/exec-query! query
{:uuid uuid})
(group-by
@ -214,7 +214,10 @@
(assoc link
:tags
(filter some?
(map :tag tags)))))))
(map :tag tags)))))
(sort-by (juxt #(-> % :schema :name)
#(-> % direction :name)
#(-> % direction :created_at)))))
(spec/def ::links-out
(spec/coll-of
@ -229,11 +232,10 @@
(target)-[:of]->(schema:schema)
OPTIONAL MATCH
(target)-[:tagged_with]->(tag:tag)
RETURN link, target, schema, tag
ORDER BY schema.name, target.name, target.created_at")
RETURN link, target, schema, tag")
(defn outgoing-links! [uuid]
{:post [(spec/assert ::links-out %)]}
(grouped-links-by-tag uuid outgoing-links :target))
(group-by-link-and-assoc-tags uuid outgoing-links :target))
(spec/def ::links-in
(spec/coll-of
@ -252,7 +254,7 @@
ORDER BY schema.name, source.name, source.created_at")
(defn incoming-links! [uuid]
{:post [(spec/assert ::links-in %)]}
(grouped-links-by-tag uuid incoming-links :source))
(group-by-link-and-assoc-tags uuid incoming-links :source))
(neo4j/defquery delete-link
"MATCH (l:link {uuid:{uuid}}),

Loading…
Cancel
Save