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:
Imdad Ahad
2017-09-08 13:26:14 +01:00
parent 3309325cd3
commit e119ced7c1
2 changed files with 21 additions and 0 deletions

View File

@@ -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))

View File

@@ -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