mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-15 19:01:50 -04:00
merge from main
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import datetime
|
||||
import re
|
||||
import time
|
||||
|
||||
@@ -8,6 +9,7 @@ from flask import current_app
|
||||
|
||||
from app import redis_store
|
||||
from app.clients import AWS_CLIENT_CONFIG
|
||||
from notifications_utils import aware_utcnow
|
||||
|
||||
FILE_LOCATION_STRUCTURE = "service-{}-notify/{}.csv"
|
||||
|
||||
@@ -58,11 +60,15 @@ def list_s3_objects():
|
||||
|
||||
bucket_name = current_app.config["CSV_UPLOAD_BUCKET"]["bucket"]
|
||||
s3_client = get_s3_client()
|
||||
# Our reports only support 7 days, but pull 8 days to avoid
|
||||
# any edge cases
|
||||
time_limit = aware_utcnow() - datetime.timedelta(days=8)
|
||||
try:
|
||||
response = s3_client.list_objects_v2(Bucket=bucket_name)
|
||||
while True:
|
||||
for obj in response.get("Contents", []):
|
||||
yield obj["Key"]
|
||||
if obj["LastModified"] >= time_limit:
|
||||
yield obj["Key"]
|
||||
if "NextContinuationToken" in response:
|
||||
response = s3_client.list_objects_v2(
|
||||
Bucket=bucket_name,
|
||||
|
||||
@@ -1070,4 +1070,14 @@ def add_test_users_to_db(generate, state, admin):
|
||||
state=state,
|
||||
platform_admin=admin,
|
||||
)
|
||||
current_app.logger.info(f"{num} {user.email_address} created")
|
||||
current_app.logger.info("User created")
|
||||
|
||||
|
||||
# generate a new salt value
|
||||
@notify_command(name="generate-salt")
|
||||
def generate_salt():
|
||||
if getenv("NOTIFY_ENVIRONMENT", "") not in ["development", "test"]:
|
||||
current_app.logger.error("Can only be run in development")
|
||||
return
|
||||
salt = secrets.token_hex(16)
|
||||
print(salt) # noqa
|
||||
|
||||
@@ -188,7 +188,8 @@ def dao_get_jobs_older_than_data_retention(notification_types):
|
||||
.all()
|
||||
)
|
||||
|
||||
end_date = today - timedelta(days=7)
|
||||
# notify-api-1287, make default data retention 7 days, 23 hours
|
||||
end_date = today - timedelta(days=7, hours=23)
|
||||
for notification_type in notification_types:
|
||||
services_with_data_retention = [
|
||||
x.service_id
|
||||
|
||||
Reference in New Issue
Block a user