Excellent! This is what I managed to come up with for my use case (listing a couple or “someday”-tasks in my daily notes, so this is form my template to be rendered with templater:
TASK
WHERE !completed AND text != "" AND !due AND !start
FLATTEN date(<%tp.date.now("YYYY-MM-DD",0,tp.file.title,"YYYY-MM-DD")%>) as Today
FLATTEN (file.ctime.year + file.ctime.hour + file.ctime.day +
file.ctime.hour + file.ctime.minute + file.ctime.second +
file.size + Today.day + Today.month + Today.year) * 15485863
as Hash
FLATTEN ((Hash * Hash * Hash) % 2038074743) / 2038074743 as Rand
SORT Rand
LIMIT 3
I don’t understand the code entirely, but it seems to work. Are those numbers (15485853 and 2038074743) arbitrary or do they represent something?
What I changed compared to Randomly order rows in a Dataview query
- Instead of the last modified time, I’m using the created time so as to avoid changes of the list when files are updated.
- And in order to stop the list from changing every time the note is reloaded, I am using the current date so that the list should stay the same the entire day.
One problem that I haven’t solved yet is to “randomize” the tasks instead of their files. Doing that would be better because currently, a note with multiple tasks will fill up the rendered list with its own tasks. I would prefer to have only one task from each note (or at least to give all tasks an equal chance to get into the selection, even once the first note hs been selected.