Simple question (hopefully). In an advance query, is there a way to do the following
-
Reduce the number of displayed rows in the block column. I do not want it to display long texts (I crossed out the lines I want to remove)
-
Or even remove ALL the cell content of the “block” column when what we find at that row is a page, not a block. Sometimes when the query has mixed results (block a properties), the block column could become annoying and just noisy…
Thank you!
Could you provide the query and some example blocks?
Sure! I will reformulate it with a detailed example.
I have a query that searches for pages and blocks that contains the string “/”
When the tag is found in a block usually it is not too noisy (visually speaking). BUT when the tag is found in a page-property, the block column of that page displays too many data.
PAGES AND BLOCKS EXAMPLE:
This page contains tags on its page-property and on one of its blocks
This page only contains tags on its page-property
QUERY CODE:
#+BEGIN_QUERY
{:title "INPUTS (blocks & pages)"
:query [:find (pull ?b [*])
:where
[?b :block/page]
[?b :block/properties ?props]
[(get ?props :tags) ?mytag]
;; I find a partial string with the tag (just because of my specific workflow)
[(str ?mytag) ?str]
[(clojure.string/includes? ?str "📬/")]
;; get and compare status
[(get ?props :status) ?mystat]
(or
[(= "🟥" ?mystat)]
[(= "🟨" ?mystat)]
)
]
}
#+END_QUERY
OUTPUT EXAMPLE:
QUESTION: How could I either
-
Remove all the data in the block column BUT ONLY when the row belongs to a page? (tag was found on a page-property, not inside a block-property). And mantain the information it is belongs to a block row (tag was found on a block).
-
OR at least, reduce the content displayed. Ideally, showing only one line. That is, the tag
Thank you!
Like a charm! thank you so much.
This works nice and I can happily continue my workflow, but after testing the solutions I’ve thought about the next modification. (And as mentioned, if it is too tricky to tackle I can live with the previous one). But I had this idea:
- Is it possible mix the page and block into only one column? I mean, to create a dedicated column (called “node” for example) and place there:
- the page link (if the tag was found on a page)
- the block link (if the tag was found on a page)
Like this
I suppose this would have something to do with the result-transform…
-
- replace
(assoc r :block/content node)
with and update
, e.g. like this
You mean like this?
:result-transform (fn [result]
(map (fn [r]
(def content (:block/content r))
(def line (first (clojure.string/split content "\n")))
(def node (if (clojure.string/includes? line "::") (get-in r [:block/page :block/original-name]) content))
(update (:parent r) :block/properties (fn [p]
(assoc p "NODE" (:content r) )
) )
) result)
)
Or like this?
:result-transform (fn [result]
(map (fn [r]
(def content (:block/content r))
(def line (first (clojure.string/split content "\n")))
(def node (if (clojure.string/includes? line "::") (get-in r [:block/page :block/original-name]) content))
(update (:parent r) :block/properties (fn [p]
(assoc r :block/content node)
) )
) result)
)
I am getting an error both ways…
Thanks
I mean like this:
:result-transform (fn [result]
(map (fn [r]
(def content (:block/content r))
(def line (first (clojure.string/split content "\n")))
(def node (if (clojure.string/includes? line "::") (get-in r [:block/page :block/original-name]) line))
(update r :block/properties (fn [p]
(assoc p "node" node)
) )
) result)
)
2 Likes
Ok. I am not a master of datalog/clojure as you can see Thank you!
btw, do you have Ko-fi or similar?
1 Like