more files

This commit is contained in:
Kenneth Kehl
2023-07-18 11:27:27 -07:00
parent 7276ed0e5a
commit a6c76f7969
3 changed files with 50 additions and 26 deletions

View File

@@ -7,6 +7,8 @@ Create Date: 2016-07-06 13:28:48.381278
"""
# revision identifiers, used by Alembic.
from sqlalchemy import text
revision = '0039_fix_notifications'
down_revision = '0038_test_api_key_type'
@@ -26,28 +28,32 @@ def upgrade():
res = results.fetchall()
for x in res:
print(' in loop {} {}'.format(x.notification_type, x.created_at))
created = x.created_at.strftime("%Y-%m-%d")
input_params = {
"created": created,
"service_id": x.service_id
}
if x.notification_type == 'email' and x.status == 'delivered':
sql = "update notification_statistics set emails_requested = emails_requested + 1, " \
"emails_delivered = emails_delivered + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set emails_requested = emails_requested + 1, " \
"emails_delivered = emails_delivered + 1 where day = date(:created) and service_id = :service_id")
if x.notification_type == 'sms' and x.status == 'delivered':
sql = "update notification_statistics set sms_requested = sms_requested + 1, " \
"sms_delivered = sms_delivered + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set sms_requested = sms_requested + 1, " \
"sms_delivered = sms_delivered + 1 where day = date(:created) and service_id = :service_id")
if x.notification_type == 'email' and x.status in ['technical-failure', 'temporary-failure', 'permanent-failure']:
sql = "update notification_statistics set emails_requested = emails_requested + 1, " \
"emails_failed = emails_failed + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set emails_requested = emails_requested + 1, " \
"emails_failed = emails_failed + 1 where day = date(:created) and service_id = :service_id")
if x.notification_type == 'sms' and x.status in ['technical-failure', 'temporary-failure', 'permanent-failure']:
sql = "update notification_statistics set sms_requested = sms_requested + 1, " \
"sms_failed = sms_failed + 1 where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set sms_requested = sms_requested + 1, " \
"sms_failed = sms_failed + 1 where day = date(:created) and service_id = :service_id")
if x.notification_type == 'email' and x.status in ['created', 'sending', 'pending']:
sql = "update notification_statistics set emails_requested = emails_requested + 1 " \
" where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set emails_requested = emails_requested + 1 " \
" where day = date(:created) and service_id = :service_id")
if x.notification_type == 'sms' and x.status in ['created', 'sending', 'pending']:
sql = "update notification_statistics set sms_requested = sms_requested + 1 " \
" where day = date('{}') and service_id = '{}'".format(created, x.service_id)
sql = text("update notification_statistics set sms_requested = sms_requested + 1 " \
" where day = date(:created) and service_id = :service_id")
print(sql)
conn.execute(sql)
conn.execute(sql, input_params)
def downgrade():
### commands auto generated by Alembic - please adjust! ###