mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
Delete delete_dvla_response_files_older_than_seven_days task
This was not being used.
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from flask import current_app
|
||||
|
||||
import pytz
|
||||
from boto3 import client, resource
|
||||
import botocore
|
||||
|
||||
@@ -89,26 +86,6 @@ def get_s3_bucket_objects(bucket_name, subfolder=''):
|
||||
return all_objects_in_bucket
|
||||
|
||||
|
||||
def filter_s3_bucket_objects_within_date_range(bucket_objects, older_than=7, limit_days=2):
|
||||
"""
|
||||
S3 returns the Object['LastModified'] as an 'offset-aware' timestamp so the
|
||||
date range filter must take this into account.
|
||||
|
||||
Additionally an additional Object is returned by S3 corresponding to the
|
||||
container directory. This is redundant and should be removed.
|
||||
|
||||
"""
|
||||
end_date = datetime.now(tz=pytz.utc) - timedelta(days=older_than)
|
||||
start_date = end_date - timedelta(days=limit_days)
|
||||
filtered_items = [item for item in bucket_objects if all([
|
||||
not item['Key'].endswith('/'),
|
||||
item['LastModified'] > start_date,
|
||||
item['LastModified'] < end_date
|
||||
])]
|
||||
|
||||
return filtered_items
|
||||
|
||||
|
||||
def remove_s3_object(bucket_name, object_key):
|
||||
obj = get_s3_object(bucket_name, object_key)
|
||||
return obj.delete()
|
||||
|
||||
Reference in New Issue
Block a user