Removed the updates to the job table to track delivery of notifications

Previously we kept a running total of job progress/success/failure on the job table. This causes contention, we now generate this data from notification history.

Removed these updates.
This commit is contained in:
Martyn Inglis
2016-08-25 09:29:53 +01:00
parent 020d998baa
commit 44bc071037
3 changed files with 0 additions and 73 deletions

View File

@@ -125,14 +125,6 @@ def dao_get_last_template_usage(template_id):
@statsd(namespace="dao")
@transactional
def dao_create_notification(notification, notification_type):
if notification.job_id:
db.session.query(Job).filter_by(
id=notification.job_id
).update({
Job.notifications_sent: Job.notifications_sent + 1,
Job.updated_at: datetime.utcnow()
})
update_count = db.session.query(NotificationStatistics).filter_by(
day=notification.created_at.date(),
service_id=notification.service_id
@@ -189,11 +181,6 @@ def _update_notification_stats_query(notification_type, status):
def _update_statistics(notification, notification_statistics_status):
if notification.job_id:
db.session.query(Job).filter_by(
id=notification.job_id
).update(_update_job_stats_query(notification_statistics_status))
db.session.query(NotificationStatistics).filter_by(
day=notification.created_at.date(),
service_id=notification.service_id
@@ -202,14 +189,6 @@ def _update_statistics(notification, notification_statistics_status):
)
def _update_job_stats_query(status):
mapping = {
STATISTICS_FAILURE: Job.notifications_failed,
STATISTICS_DELIVERED: Job.notifications_delivered
}
return {mapping[status]: mapping[status] + 1}
def _decide_permanent_temporary_failure(current_status, status):
# Firetext will send pending, then send either succes or fail.
# If we go from pending to delivered we need to set failure type as temporary-failure