mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-13 00:32:16 -05:00
Add command to populate service_email_reply_to:
* Insert new entries for unpopulated services * Exclude services who do not have a reply to set
This commit is contained in:
@@ -228,3 +228,23 @@ class BackfillProcessingTime(Command):
|
||||
process_end_date.isoformat()
|
||||
))
|
||||
send_processing_time_for_start_and_end(process_start_date, process_end_date)
|
||||
|
||||
|
||||
class PopulateServiceEmailReplyTo(Command):
|
||||
|
||||
def run(self):
|
||||
services_to_update = """
|
||||
INSERT INTO service_email_reply_to(id, service_id, email_address, is_default, created_at)
|
||||
SELECT '{}', id, reply_to_email_address, true, '{}'
|
||||
FROM services
|
||||
WHERE reply_to_email_address IS NOT NULL
|
||||
AND id NOT IN(
|
||||
SELECT service_id
|
||||
FROM service_email_reply_to
|
||||
)
|
||||
""".format(uuid.uuid4(), datetime.utcnow())
|
||||
|
||||
result = db.session.execute(services_to_update)
|
||||
db.session.commit()
|
||||
|
||||
print("Populated email reply to adderesses for {}".format(result.rowcount))
|
||||
|
||||
@@ -18,6 +18,7 @@ manager.add_command('purge_functional_test_data', commands.PurgeFunctionalTestDa
|
||||
manager.add_command('custom_db_script', commands.CustomDbScript)
|
||||
manager.add_command('populate_monthly_billing', commands.PopulateMonthlyBilling)
|
||||
manager.add_command('backfill_processing_time', commands.BackfillProcessingTime)
|
||||
manager.add_command('populate_service_email_reply_to', commands.PopulateServiceEmailReplyTo)
|
||||
|
||||
|
||||
@manager.command
|
||||
|
||||
Reference in New Issue
Block a user