I found a useful article with a query for journal entries from previous years on the same date (link). I modified it to show me all the journal pages from a specified month. I then modified it to return only the values of a specified page property from those journal pages.
#+BEGIN_QUERY
{:title "Month Attendance"
; Pull the pages rather than the blocks. We want to show journal pages that have the attendance property defined
:query [:find (pull ?p [*])
; Filter on today, so get that information as a variable to the query
:in $ ?yyyymm
:where
; First, restrict the results to only journal pages
[?b :block/page ?p]
[?p :page/journal? true]
; Load the journal page properties into ?properties
[?p :block/properties ?properties]
; Get the attendance property
(has-page-property ?p :attendance)
; Fetch the day of the journal page and store it in ?jd
[?p :page/journal-day ?jd]
; Turn the journal date into YYYYMMDD string and store it in ?jds
[(str ?jd) ?jds]
; Use subs to cut off the DD and store the YYYYMM in ?journalYYYYMM
[(subs ?jds 0 6) ?journalYYYYMM]
; Keep only those journal pages whose YYYYMM are equal to the specified argument
[(= ?journalYYYYMM ?yyyymm)]
]
; Make logseq provide today's date. Use double quotes rather than single so things work.
:inputs ["202308"]
}
#+END_QUERY
This mostly does what I want. There are some improvements I would like to make, but I’m not sure how.
- I would like to be able to insert this into a page multiple times as a method call rather than copying and pasting the entire query. I would like to have an Attendance page that showed results for each month separately.
- I would like to convert the result table into something with a calendar view. I have tried to do this by modifying the Block Calendar plugin, but found that the resulting display didn’t persist when I exported public pages to HTML.