Recurring todo list

Howdy - firstly I love the platform and can’t wait to properly get stuck in!

Just curious and looking for some advice on how I’d achieve a specific feature in my app - the flow would be a user adds a task (take out trash) and a frequency (days / weeks). This would then populate a todo list for that particular day that contains their tasks for the day - the idea that the user would set up a bunch of tasks like

Take out the trash every 2 days
Load the dishwasher every 1 days
Clean the car every 2 weeks

But when they check their todo list they would only see the tasks that fall on that day - is that kind of thing possible with AppGyver?

Thanks in advance!

1 Like

Hi Connor, welcome to the community! And yes that sounds very possible :slight_smile:

I would implement this the following way:

Create a database of tasks with:

  • name of the task
  • frequency of the task as number
  • frequency in units (weeks / days / months)
  • when is the next date to do it.

For example:
Tasks = [{name: "Take out the trash", frequency: 2, units: "days", nextDate: 2021-05-02}, {name: "Wash the car", frequency: 2, units: "weeks", nextDate: 2021-05-03}]

These videos give you a good quick overview on how to work with data resources in Composer.

For setting the dates, there are two very useful formulas:

  • NOW() gives you today’s date.
  • ADD_DURATION() lets you add a certain duration to a given date in the units you define. (docs)

When the user creates for example the car wash task for themselves in a form, I would take the name and frequencies of the task from the form fields/dropdowns, but then calculate nextDate with the formula ADD_DURATION(NOW(), frequency, units)

Then in the to-do list view, to show only today’s tasks, I would use the formula SELECT(data.Tasks, DATETIME_IS_SAME(item.nextDate, NOW(), "day")) where data.Tasks is the whole list.

Perhaps the trickiest part is that you need to update the value of nextDate again whenever the day has come to do the task, but you cannot change it before the day ends, otherwise it won’t appear in the list :thinking:.

I would do this so that any task whose nextDate is in the past updates when the to-do page is opened.

First I would go through the Tasks list and check if an item is in the past with DATETIME_IS_BEFORE(item.nextDate, NOW(), "day"), item). If yes, I would change the item’s nextDate property to ADD_DURATION(item.nextDate, item.frequency, item.units) to update it to the next value.

This is just one take on how to approach something like this, but hope it gave you some idea how to move forward! :slight_smile:

1 Like