I utilise the possibility to filter out elements in a daisy chain. So it starts with all lines in the file, keeps only those having the tomato, and then only keeps lines having the correct date (in the correct place), and then take the length of this list, aka the pomodoroCount.
Thats, at least in my opinion, definitely a better way to achieve this! Thank you!
But I think I didn’t make myself clear enough in my initial post. I’m looking for a way to automatically update the frontmatter with the Pomodoros I’ve done today, without having to copy and paste to the frontmatter.
Ah… Read that, and forgot about it. This is sketchy stuff, as we might very well end up with some race conditions, but the following seems to work somewhat reliably:
What happens here, is that it calculates the stuff, as before, but then it sets a timeout to execute a change to the frontmatter after 2000 milliseconds, aka 2 seconds. If it doesn’t work, you might need to change that factor up (or down) a little.
Disclaimer: I’m not sure how reliable this is when running live preview, or doing other changes almost at the same time. I don’t think it should be harmful, but I do feel like the need to mention this is kind of sketchy, so use at own risk.