Skip to content

Delete archived letter attachments from s3#4894

Open
CrystalPea wants to merge 10 commits into
mainfrom
delete-archived-letter-attachments-from-s3
Open

Delete archived letter attachments from s3#4894
CrystalPea wants to merge 10 commits into
mainfrom
delete-archived-letter-attachments-from-s3

Conversation

@CrystalPea

@CrystalPea CrystalPea commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

I used remove_archived_template_email_files_from_s3() task as a base for this new task.

I had to adjust it, as letter attachments are a bit different. I did some refactoring on the way, and de-duplicated the code shared between the tasks.

I have pushed these changes to dev-b, and functional tests pass: https://concourse.notify.tools/teams/dev-b/pipelines/deploy-notify/jobs/functional-tests/builds/520

I also did manual testing.

I needed to make letter attachments S3 bucket available to api apps: https://github.com/alphagov/notifications-aws/pull/3045 (this needs to be merged / possibly terraform to be run first)

After that, the task worked as expected:
Screenshot 2026-07-09 at 16 08 40

Function based on a similar task for template email files
@CrystalPea CrystalPea force-pushed the delete-archived-letter-attachments-from-s3 branch 2 times, most recently from 1e2c76e to 5599157 Compare June 25, 2026 10:57
for scoped files.

Also move archiving a letter attachment into a dao method
- that's a more appropriate place for it.
The scoping datetimes archived_before and archived_after were
defined as timezone-aware datetimes, which didn't play well
with the naive datetimes from the db (for archived_at) field.

After a Slack discussion, I decided to try the approach from
sqlalchemy docs to try and fix it:
https://docs.sqlalchemy.org/en/20/core/custom_types.html#store-timezone-aware-timestamps-as-timezone-naive-utc

The scoping now works as expected.
@CrystalPea CrystalPea force-pushed the delete-archived-letter-attachments-from-s3 branch from 5599157 to d809694 Compare June 25, 2026 14:42
@CrystalPea CrystalPea force-pushed the delete-archived-letter-attachments-from-s3 branch 2 times, most recently from d7abe81 to 5f4d19a Compare June 25, 2026 17:12
between two tasks instead of duplicating it.
@CrystalPea CrystalPea force-pushed the delete-archived-letter-attachments-from-s3 branch from 5f4d19a to f13be34 Compare June 26, 2026 14:57
@CrystalPea CrystalPea marked this pull request as ready for review June 26, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant