Cleaning Up a Messy Graph

I have a workflow page with a bunch of sanity check queries on it.

Here’s a few general ones for your use :saluting_face:

#+BEGIN_QUERY
{:title [:b "Tasks without tag"]
 :query [:find (pull ?b [*])
  :where
   [?b :block/marker ?mark]
   [(contains? #{"TODO" "LATER"} ?mark)]
   [?m :block/original-name ?mark]
   (not 
     [?b :block/refs ?r]
     [(!= ?m ?r)]
   )
   [?b :block/page ?p]
   [?p :block/journal? true]
 ]
 :breadcrumb-show? false
}
#+END_QUERY
#+BEGIN_QUERY 
{:title [:b "Broken References"]
 :query [:find (pull ?b [*])
  :in $ ?matcher
  :where
   [(re-pattern ?matcher) ?regex]
   [?b :block/content ?c]
   [(re-find ?regex ?c)]
   [?b :block/refs ?br]
   [(missing? $ ?br :block/content)]
   [(missing? $ ?br :block/name)]
 ]
 :inputs [ "\\([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\)"]
}
#+END_QUERY

(I hope this one still works as of today lol)

#+BEGIN_QUERY
{:title [:b "Empty files"]
 :query [:find (pull ?p [*])
  :where
   [?p :block/journal? false]
   [?p :block/file _]
   (not 
     [?b :block/page ?p]
     (not [?b :block/content ""] )
   )
 ]
}
#+END_QUERY
#+BEGIN_QUERY
{:title [:b "orphan pages"]
 :query [:find (pull ?p [*])
  :where
   [?p :block/file _]
   [?p :block/name ?name]
   (not [(clojure.string/starts-with? ?name "hls__")])
   [(missing? $ ?p :block/namespace)]
   (not (or
     [?b :block/refs ?p]
     [?b :block/page ?p]
   ) )
 ]
}
#+END_QUERY
8 Likes