rubyforgood / homeward-tails

Homeward Tails is an application making it easy to link adopters/fosters with pets. We work with grassroots pet rescue organizations to understand how we can make the most impact.
MIT License
69 stars 117 forks source link

Pet Task Epic: As staff I can create a default pet task that is recurring and set the #508

Closed kasugaijin closed 7 months ago

kasugaijin commented 8 months ago

Staff can currently create Default Pet Tasks. These are tasks that are automatically created on new pet, when that pet is created. This is for common tasks that always apply, and saves the staff from having to manually create them on each pet.

Tasks now have recurring functionality. That is, staff can create/edit a task on a pet and set it as recurring, and also set a next_due_date_in_days value. When this recurring task is marked complete, a new, identical task is created, and its due date will be today + the next_due_date_in_days value.

This ticket is to add two a new attribute to Default Pet Tasks that will create recurring tasks on a pet.

Acceptance criteria: Add to DefaultPetTask (table, model, form)

nsiwnf commented 8 months ago

Do we need design for this? Seems like staff needs some sort of UI to manage default tasks

nsiwnf commented 8 months ago

I feel like there could be different scenarios for default pet tasks? ex. On add pet (draft mode) -> add tasks: fill in pet details (not recurring), vaccine reminders (recurring) On app submitted for pet -> add tasks: review application (not recurring)

kasugaijin commented 8 months ago

@nsiwnf there’s already a default pet task flow in main for staff to add default pet tasks (see dashboard sidenav) so this issue shouldn’t need any design. These are used to create a new task on creation of a new pet.

I do like the idea of tethering other tasks to certain events too, though. But currently this flow is just for adding tasks to a Pet when the pet is created.

kasugaijin commented 8 months ago

Anyone interested in this ticket - let me know if you have questions! Here or in slack.

jmilljr24 commented 7 months ago

I can work on this.

Just some clarification.

* Update the TaskService to create the first task. Due date will be Time.current + next_due_date_in_days

This is assuming an initial due date was not submitted? Would there be a scenario for example, where the staff would want the initial due date to be 5 days out then the recurrence would be every 10 days going forward?

Something along the lines of if task.due_date is nil then Time.current + next_due_date_in_days else task.due_date Or would you prefer in the form to disable the due_date field if recurring is selected and enable the next_due_date_in_days?

Also the actual tasks allows for recurring to be true but with no due date. No sure of your thoughts on how that fits into all of this.

kasugaijin commented 7 months ago

All yours!

So the Default Pet Task form/model doesn't have a due date. We use the due_in_days to calculate the Task's due date in the Service. But this does remind me that my initial ticket is incorrect as we do not need to include a next_due_in_days in the migration. We can use the existing due_in_days field to create the due date and set the next_due_in_days on the Task when it is created. I updated the issue description :) Does that make sense?

image
jmilljr24 commented 7 months ago

Yes! Thank you.