Hi I wonder how I can calculate number of back links in certain page. Say I collect Links (articles, tweets) and tags them with properties include one called Topics, where I spell out which topic this links is referenced to. Then I have a query to pull out all Topics : {{Query (page-property type [[topics]]}} . But I can’t see number of Links each Topic is back linked to.
Under All Pages, I can see number of back links but I don’t know how to filter by pages that are only topic.
Thanks, here you go! I guess this involved in Aggregating function.
" I collect articles as reference links (“Links”) and assign them to Topics (“Topics”). I need to calculate how many links each topic has collected as an indicator which topic is the priority to work on (the one with the most reference links). Currently the Links’s property include "Type:: Link , Topic:: Topic 1, Topic 2 " ; a topic’s property include “Type:: topic ; "
I guess I can use Sum or Max function but I have no experience in using them. Maybe I can add a property like " Reference-count:1 " so the query can count the value ('1”) if so whats the full query look like ? Thank so much!
Hi there ! Somehow it didn’t return any result. While I am RE-exam the prospect to fit into your scrip, I just learned Logseq does have a SUM function. https://docs.logseq.com/#/page/64076691-bea5-429c-a43c-dc9ea8e31e01
Do you think in my case , I can include property “qty” for each link and because each link gets to count once, so by default qty::1 . Then use SUM to calculate the total Links for each Topic. If so do you know how should I write the query? And how can I have the count of total links showed up like under All Pages , back links automatically showed up in the table as a column? I hope I made myself clear . :-p ) if not I can do a few rendering or screenshot to explain.
As you can see in the example on the site, you would need a query per topic.
Because it would do a sum across the table.
I’m more curious as to why you do not get any results from my query.
Here’s a screenshot of what the article page looks like:
Hi I am still trying using the query here. Just so you know under a Topic , which is a page, I have property type such as type:: [[topics]] but I don’t have a property as topic:: ( title of the topic) . Should I add the later in order to run your query?
Thank you!
Hi @Siferiax - your queries are so helpful. I’ve been struggling with this precise one. I want to make it a query for pages which have a property that is a link to the current page. (In this case child projects which reference a parent project).
But I can’t seem to get it to work with the using current-page or query-page as an input (which I want to do to make it a template). I had an idea to try the properties-text-values and came up with the equivalent code to what you’ve put here but it doesn’t seem to work.
[?p :block/properties-text-values ?prop]
[(get ?prop :parent) ?parent]
[(= ?parent "[[House & Family]]")] ; NB I've tried upper and lower case.
I’ve looked in the block properties and it’s got that precise text so I’m a bit stumped. Any help gratefully received.
Yeah you run into a text vs reference sort of issue.
I also learned better how to get the set data to work when properties use page references.
The translation from name to original-name is necessary as in your property value it is the original-name and in the input value it is the name.
Instead of clojure.string/includes? you can also use contains? and not use text-values.
Thanks - that’s much neater. Still struggling with some of this as some of these nuances (e.g. sets rather than plain text) are not obvious but I’m getting there.