Cleaning Up a Messy Graph

Edit: see comment below. I misunderstood the purpose of the Empty Files query.

As given, the empty files query includes pages that have linked references to them.

To exclude empty pages that have linked references, just add (not [?refs :block/refs ?p]):

In light of @Siferiax’s clarification, here’s something that might be more useful than what I had previously posted. Adaptation of the orphan pages query that finds empty files that are also orphan pages:

#+BEGIN_QUERY
{:title [:h3 "Orphaned empty page files"]
  :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]
          (and
            [?b :block/page ?p]
            (not [?b :block/content ""])
          )
        )
      )
    ]
}
#+END_QUERY
1 Like