Closed RemyMachado closed 7 months ago
@RemyMachado I've considered this, but it's more work than you might think. The automated recurring tasks workflow simply changes the Due date and Status of a single page.
But for a habit tracker, you'd want it to create a brand-new page.
While we could definitely modify it for that purpose, it'd require a lot of design considerations. Not impossible by any means, but different enough that it'd be a totally separate project, rather than a PR for this one!
I'm missing too much context to understand the ins and outs. I believed that we'd only need to add two properties to the task database in order to allow streaks computations via Pipedream. I do not understand why we would have to create a brand-new page. I was thinking about using a formula field that would do the computations you show in your tutorial, but instead of being attached to a checkbox it would be attached to the task template (DB row of All tasks [UB]
) and it would be our responsibility to create the views and galleries that suit each of us.
Anyway, I'll try to investigate and I'll let you know if I find anything interesting in this journey.
@RemyMachado so for a habit tracker, you need a new entry each day.
If you're doing it like my recent Level 5 habit tracker, it's a page for each day. If you're building it the "true" way (https://thomasjfrank.com/5-ways-to-build-a-habit-tracker-in-notion-free-template-included/#true-habit-tracker), then you need a new entry for each habit on each day (multiple entries each day).
This automation merely queries your selected database for Done tasks that have a Next Due date. When it finds them, it sets the Due date to the date from Next Due, and it sets Done back to Not Started (or unchecks a Done checkbox). It's just modifying the properties on the pages found in the query.
Though, technically, you could adjust this for a different of habit tracking, where the automation increments a Number property for streak tracking. I likely won't add that to this automation, just because I don't want to make it any more confusing for the average user who just wants normal recurring task processing. But it's something you could add to your own component!
So, in order to implement the Streaks
feature, I familiarized myself with Pipedream and the Notion-API and added two properties to the All Tasks
database:
Current Streak: number
Longest Streak: number
As one would think we need to add these instructions to your Pipedream workflow:
for (const pageToUpdate of pagesToUpdate) {
const dueDateString = pageToUpdate.properties.Due.date.start
const isOverdue = isTaskOverdue(dueDateString)
const oldCurrentStreak = pageToUpdate.properties["Current Streak"].number || 0
const newCurrentStreak = isOverdue ? 0 : oldCurrentStreak + 1
const oldLongestStreak = pageToUpdate.properties["Longest Streak"].number || 0
const newLongestStreak = Math.max(newCurrentStreak, oldLongestStreak)
// update()
// ...
}
After making these adjustments I finally realised what you were explaining to me about the differences between the tasks and the habits pages and how they don't achieve the same goal.
Anyway, I'm quite happy with the new feature for my All Tasks
database even though it's not as nice as your habits tracker, especially about the daily score progress bar you made. I have an ugly percentage that I'm not even sure I can round, but I'm fine with it:
Thank you!
Glad you were able to get this added to your system! That code looks good well-written for the use case.
After finding your Habits streaks tracker Notion template and watching your tutorial on the subject, I was left with the same interrogations as you about "How to use it with databases?".
I also read your blog and the issues you encountered with it:
Finally I was thinking:
Why not use the "Ultimate Tasks" template in addition to the automated recurring tasks setup in order to build an even better habit tracker?
It would require a bit of modification to the Pipedream workflow, but we could add for each task a Pipedream-updated counter property that would increment each time the task was done on time and reset when not. We could also add a second property to keep track of the longest streak.
What do you think?
I'll try to familiarize with Pipedream and eventually submit a PR. If you already know how to do it and want to, don't wait for me.