Thanks for the suggestion @Siferiax, I mostly wanted to have a getWeekDay
function to use within :where
to only find certain days. Iām not sure if the view supports filtering, but even if it does, I suppose thatās a little bit of a hack since why pass through the query if I filter it out of the view?
I wanted the function to return short day names, so I could display a block if it has a property preview-on-day-of-week
with value as a string for each day of the week, so that I could find blocks that have this property with value matching (getWeekDay :today)
, which I implemented via a query, where I stole @mentaloidās weekday implementation and got the string value from the day of week numeric key.
{:title "š PERIODIC"
:rules [
[(getWeekDay ?date-a)
[(mod ?date-a 100) ?monthday-a]
[(mod ?date-a 10000) ?mod-a]
[(quot ?mod-a 100) ?month-a]
[(- ?month-a 8) ?month8-a]
[(quot ?month8-a 6) ?month6-a]
[(* ?month6-a 12) ?month12-a]
[(- ?month-a ?month12-a) ?monthnum-a]
[(inc ?monthnum-a) ?monthinc-a]
[(* 13 ?monthinc-a) ?month13-a]
[(quot ?month13-a 5) ?month5-a]
[(quot ?date-a 10000) ?year-a]
[(+ ?year-a ?month6-a) ?year6-a]
[(mod ?year6-a 100) ?yearnum-a]
[(quot ?yearnum-a 4) ?year4-a]
[(quot ?year6-a 100) ?century-a]
[(quot ?century-a 4) ?century4-a]
[(* 5 ?century-a) ?century5-a]
[(+ ?monthday-a ?month5-a ?yearnum-a ?year4-a ?century4-a ?century5-a) ?sum-a]
[(mod ?sum-a 7) ?d]
[(get {
0 "Sat"
1 "Sun"
2 "Mon"
3 "Tue"
4 "Wed"
5 "Thu"
6 "Fri"
} ?d)]]
]
:query [:find (pull ?h [*])
:in $ ?query-pg
:where
(has-property ?h :preview-on-day-of-week)
[(property ?h :preview-on-day-of-week) ?day]
[?query-pg :block/journal-date ?query-date]
[(getWeekDay ?query-date) ?query-day]
(= ?query-day ?day)
]
:inputs [:query-page]
:group-by-page? false
:collapsed? false}
which does not work as I expect, but Iām able to get this to work for literals, like so
:query [:find (pull ?h [*])
:where
(has-property ?h :preview-on-day-of-week)
[property ?h :preview-on-day-of-week "Sun"]
]
So I expect Iām reading the property in ?day
correctly, but Iām not sure how I debug the function that returns the string for the day of the date input, as having the target day of week be specified by the journal date from where the query is called instead of using a literal.
but maybe I should backtrack.
My use case where I want to see something that appears on a weekly schedule: itās my workout routine. I schedule a routine each day of the week that I modify every 4-6 months because of the seasons. I initially set this to be a task as itās something thatās not done that I wish to do, but as itās recurring and itās a description, it really fills up my general todo list queries.
While Iād like to figure out how to write these queries without feeling like itās all trial and error, I also want to learn how else I might be able to accomplish this otherwise, I think my use case question is,
How might I have tasks annotated in detail without having long list (in screen space, not in number) query results?
I considered,
- a
query-verbosity
property of a whole number, which is difficult to modify over time
- enforcing a policy of task children must all be tasks and task details must be a reference.
- default task query results as collapsed.
Numbers 2. and 3. seem within the logseq philosophy