GTBitsOfGood / angels-among-us

Rescue one until there are none
https://staging--angels-among-us.netlify.app
MIT License
4 stars 0 forks source link

[Consistency] [BE] Cron job to delete unused post attachments #181

Open katsukixyz opened 1 year ago

katsukixyz commented 1 year ago

Context

We have implemented post deletion functionality in a previous sprint. However, we need to handle the case in which attachment deletion from the storage bucket fails during post deletion. We want to add a cron job to remove all the missed deletions so that we don't incur extra cost.

Requirements

You are to write a cron job using Netlify Scheduled Functions. This cron job should be invoked once every day and should do the following:

  1. Fetch all storage bucket objects. The object keys are in the form postId/attachmentName.fileExtension.
  2. Fetch all posts that are pending: false.
  3. Determine the attachments (bucket objects) that are not associated with any posts.
  4. Delete those attachments (retry 3 times).

For testing, you can contact your engineering leadership for our storage bucket credentials to make sure your function invocation does what it is intended to do.

Acceptance Criteria

PM

EM