Query list of all pages I created or updated during last 7 days

Hi All,

just starting to getting grips on advanced queries.

I would like to have a list of all pages I created or updated during last 7 days for my weekly review.
The query below returns blocks not pages, so I’m missing something apparently.

Any pointers on what I would be doing wrong?

PS I tried these: How to use queries to get list of pages instead of blocks? - Questions & Help - Logseq and List of recently created/modified pages (timestamp issues) - Look what I built - Logseq but those return my entire graph.

Tia, gr. Michel

#+BEGIN_QUERY
{
 :title [:b "Alle pagina's die afgelopen week aangeraakt zijn"]
 :query [
         :find (pull ?p [*]) 
         :in $ ?start ?today
         :where 
         (between ?p ?start ?today)
         ]
         :inputs [:7d-before :today ]
}
#+END_QUERY
1 Like

I’m thinking you are looking specifically for journal pages going by your query.
I’m going to change it to actual advanced query language and not a mismatch between simple and advanced queries. Because honestly simple queries confuse me :smiley:
Anyway what happens is the query doesn’t know we’re asking for pages and not blocks. I have to explicitly say that ?p is the page ?b is on, even though I don’t use ?b.

#+BEGIN_QUERY
{:title [:b "Alle pagina's die afgelopen week aangeraakt zijn"]
 :query [:find (pull ?p [*])
         :in $ ?start ?today
         :where
         [?p :block/journal-day ?d]
         [(>= ?d ?start)]
         [(<= ?d ?today)]
         [?b :block/page ?p]
         ]
 :inputs [:7d-before :today]
}
#+END_QUERY

PS. I think between is to be used with blocks anyway?

Thanks! I indeed get a nice list of all Journals of the last week.

Actually, I’m looking of a list of ALL pages I created or updated last week, not just journal pages. For my weekly review I would like to check everything I did in my PKM to see if I need to refine and or refactor pages and blocks.
I tried changing block/journal-day to block/name, but then the list remains empty.

1 Like

:block/name would be the lower-case name of the page :slight_smile:
For this we will need to do something slightly different. Though do be aware that the updated-at value is not reliable in some situations. So it may show more pages due to them getting their updated-at value updated. Same goes for created-at. (you don’t need to use it, because at time of creation updated-at will get the same value)

#+BEGIN_QUERY
{:title [:b "Alle pagina's die afgelopen week aangeraakt zijn"]
 :query [:find (pull ?p [*])
         :in $ ?start ?today
         :where
         [?p :block/updated-at ?d]
         [(>= ?d ?start)]
         [(<= ?d ?today)]
         [?b :block/page ?p]
         ]
 :inputs [:7d-before-ms :end-of-today-ms]
}
#+END_QUERY
2 Likes

Thanks a lot! I still get hundreds of files in the resultset, which probably has to do with the unreliable updated-at value. It also varies per laptop, strangely.

Thanks again!

when I run the script I get over 3500 hits. is there any modification the word lend toward a more accurate result?

Unsure what you are looking for? As already stated updated-at is unreliable in some cases.
I have heard elsewhere that created-at and updated-at get set to current datetime the moment you re-index your graph.

Yes, that would explain my experience. When I first tested the query, I got the expected 15-20 results. After reindexing, I got every page in the graph (over 3000). Not helpful. I hope for the future is that re-index does not change the original update-at and createe-at properties.
Thanks for reply

1 Like