casa icon indicating copy to clipboard operation
casa copied to clipboard

Periodically cleanup case contact drafts

Open schoork opened this issue 1 year ago • 22 comments

What type(s) of user does this feature affect?

  • volunteer

Description

#5414 introduced the potential for case contact drafts to not be attached to a Casa Case (or cases). In this situation, if a user leaves step 1 without selecting at least one casa case, they will not be able to return to that draft.

We need to introduce a way to clean these up periodically (delete them). They should be any case contacts that meet the following criteria:

  1. draft_case_ids is empty
  2. case contact was created more than 1 days ago

We also want to delete old drafts in general.

  • Any draft older than a week should get deleted.

Make sure to write tests!!!

As part of this work

  • You may need to introduce a tool to run rake tasks or jobs periodically. One such tool is the whenever gem (but you could use a different one).
  • If introduces a tool (like above) then incorporate with #5328 to make sure this runs on the 15th of every month

Alternatively similar to #5328 this could be done as a rake task that will then be run using the heroku scheduler

Screenshots of current behavior, if any

You can paste images on the clipboard here

How to access the QA site

Login Details:
Link to QA site

Login Emails:

password for all users: 12345678

Questions? Join Slack!

We highly recommend that you join us in slack #casa channel to ask questions quickly. And discord for office hours (currently Tuesday 5-7pm Pacific), stakeholder news, and upcoming new issues.

schoork avatar Dec 17 '23 12:12 schoork

I can work on this.

phonghpham avatar Dec 17 '23 13:12 phonghpham

Thanks @phonghpham. It's not quite ready to be worked, since it needs the PR it mentions to be merged first. When it's ready, will circle back to see if you still want to do it.

schoork avatar Dec 18 '23 11:12 schoork

@phonghpham The blocking issue and PR has been merged. So this is ready if you want it.

schoork avatar Jan 15 '24 21:01 schoork

Hello! One question about this issue. From what I could see in the controller, what defines a draft is status being different from "active". Wouldn't this change also delete old case contacts? since they have "started" status by default and empty draft_case_ids

andreLumor avatar Jan 30 '24 20:01 andreLumor

There was an after party task that ran on deployment that set their status as active.

schoork avatar Jan 30 '24 22:01 schoork

@andreLumor lib/tasks/deployment/20231125151610_set_case_contacts_as_active.rake

schoork avatar Jan 31 '24 03:01 schoork

Perfect then! I can start working on the issue if you wish.

andreLumor avatar Jan 31 '24 13:01 andreLumor

This issue has been inactive for 250 hours (10.42 days) and will be unassigned after 110 more hours (4.58 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time

github-actions[bot] avatar Feb 11 '24 00:02 github-actions[bot]

This issue has been inactive for 370 hours (15.42 days) and is past the limit of 360 hours (15.00 days) so is being unassigned.You’ve just been unassigned from this ticket due to inactivity – but feel free to pick it back up (or a new one!) in the future! Thank you again for your contribution to this project.

github-actions[bot] avatar Feb 16 '24 00:02 github-actions[bot]

Hey @schoork, had some time issues, but now I can finish this task. One thing I was wondering is the usage of the whenever gem, since it (and other cron gems) doesn't work with heroku apps. (https://github.com/javan/whenever?tab=readme-ov-file#heroku). Wouldn't it be better to keep using heroku scheduler, as in the linked birthday reminder task?

andreLumor avatar Mar 26 '24 13:03 andreLumor

Hey @schoork, had some time issues, but now I can finish this task. One thing I was wondering is the usage of the whenever gem, since it (and other cron gems) doesn't work with heroku apps. (https://github.com/javan/whenever?tab=readme-ov-file#heroku). Wouldn't it be better to keep using heroku scheduler, as in the linked birthday reminder task?

Yeah, didn't know that about Heroku and cron, but Heroku scheduler sounds good.

schoork avatar May 20 '24 14:05 schoork

@schoork Where is the 1 day coming from?

Is there any situation where a draft without a case ID might hang around for longer than that and be otherwise accessible? Me and Linda talked a bit about this today and really want to avoid a situation were useful data is deleted.

elasticspoon avatar May 26 '24 23:05 elasticspoon

@schoork Where is the 1 day coming from?

Is there any situation where a draft without a case ID might hang around for longer than that and be otherwise accessible? Me and Linda talked a bit about this today and really want to avoid a situation were useful data is deleted.

I think it was something Brandon and I may have discussed (or maybe I just made it up). I'm totally cool with extending it, or even having a database flag where a user could mark it for deletion. Also, if this is not an issue for users, then we should just close it as not doing.

schoork avatar May 27 '24 14:05 schoork

I would like to work on this

Smullz622 avatar Jul 12 '24 20:07 Smullz622

I would like to work on this

It is yours, @Smullz622!

schoork avatar Jul 13 '24 14:07 schoork

This issue has been inactive for 249 hours (10.38 days) and will be unassigned after 111 more hours (4.63 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time

github-actions[bot] avatar Jul 24 '24 00:07 github-actions[bot]

Still working. The pr is out but on hold until stakeholders confirm all drafts should be cleared after one week

Smullz622 avatar Jul 24 '24 12:07 Smullz622

This issue has been inactive for 252 hours (10.50 days) and will be unassigned after 108 more hours (4.50 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time

github-actions[bot] avatar Aug 04 '24 00:08 github-actions[bot]

Still on hold until stakeholders confirm all drafts should be cleared after one week

Smullz622 avatar Aug 05 '24 12:08 Smullz622

This issue has been inactive for 252 hours (10.50 days) and will be unassigned after 108 more hours (4.50 days). If you have questions, please

If you are still working on this, comment here to tell the bot to give you more time

github-actions[bot] avatar Aug 16 '24 00:08 github-actions[bot]

This issue has been inactive for 372 hours (15.50 days) and is past the limit of 360 hours (15.00 days) so is being unassigned.You’ve just been unassigned from this ticket due to inactivity – but feel free to pick it back up (or a new one!) in the future! Thank you again for your contribution to this project.

github-actions[bot] avatar Aug 21 '24 00:08 github-actions[bot]