New notification stats table

- to capture the counts of things that we do
- initial commit captures when we create an email or sms

DOES NOT know about ultimate success only that we asked our partners to ship the notification

Requires some updates when we retry sending in event of error.
This commit is contained in:
Martyn Inglis
2016-03-08 15:23:19 +00:00
parent e99331315e
commit f5f50e00ff
7 changed files with 389 additions and 31 deletions

View File

@@ -0,0 +1,41 @@
"""empty message
Revision ID: 0036_notification_stats
Revises: 0035_default_sent_count
Create Date: 2016-03-08 11:16:25.659463
"""
# revision identifiers, used by Alembic.
revision = '0036_notification_stats'
down_revision = '0035_default_sent_count'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('service_notification_stats',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('day', sa.String(length=255), nullable=False),
sa.Column('service_id', postgresql.UUID(as_uuid=True), nullable=False),
sa.Column('emails_requested', sa.BigInteger(), nullable=False),
sa.Column('emails_delivered', sa.BigInteger(), nullable=True),
sa.Column('emails_error', sa.BigInteger(), nullable=True),
sa.Column('sms_requested', sa.BigInteger(), nullable=False),
sa.Column('sms_delivered', sa.BigInteger(), nullable=True),
sa.Column('sms_error', sa.BigInteger(), nullable=True),
sa.ForeignKeyConstraint(['service_id'], ['services.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('service_id', 'day', name='uix_service_to_day')
)
op.create_index(op.f('ix_service_notification_stats_service_id'), 'service_notification_stats', ['service_id'], unique=False)
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_service_notification_stats_service_id'), table_name='service_notification_stats')
op.drop_table('service_notification_stats')
### end Alembic commands ###