Removed updates to templates statistics

- on create notification we updated the templates stats to record the usage.
- this is now based on notification history
- this update and associated tests are now removed,
This commit is contained in:
Martyn Inglis
2016-08-25 10:12:39 +01:00
parent 44bc071037
commit 84ea173ced
2 changed files with 2 additions and 148 deletions

View File

@@ -16,7 +16,6 @@ from app.models import (
Service,
Notification,
NotificationHistory,
Job,
NotificationStatistics,
TemplateStatistics,
SMS_TYPE,
@@ -139,17 +138,6 @@ def dao_create_notification(notification, notification_type):
)
db.session.add(stats)
update_count = db.session.query(TemplateStatistics).filter_by(
day=date.today(),
service_id=notification.service_id,
template_id=notification.template_id
).update({'usage_count': TemplateStatistics.usage_count + 1, 'updated_at': datetime.utcnow()})
if update_count == 0:
template_stats = TemplateStatistics(template_id=notification.template_id,
service_id=notification.service_id)
db.session.add(template_stats)
if not notification.id:
# need to populate defaulted fields before we create the notification history object
notification.id = uuid.uuid4()