fix sorting

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

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

Loading…
Cancel
Save