mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04:00
Removed updates to the provider stats table
- again these new come from the notifications history table - We update this when we sent a notification, so removed from celery tasks - tests removed also
This commit is contained in:
@@ -13,7 +13,6 @@ from app import notify_celery, statsd_client, clients, create_uuid
|
||||
from app.clients.email import EmailClientException
|
||||
from app.clients.sms import SmsClientException
|
||||
from app.dao.notifications_dao import (
|
||||
update_provider_stats,
|
||||
get_notification_by_id,
|
||||
dao_update_notification,
|
||||
update_notification_status_by_id
|
||||
@@ -78,13 +77,6 @@ def send_sms_to_provider(self, service_id, notification_id):
|
||||
)
|
||||
notification.billable_units = get_sms_fragment_count(template.replaced_content_count)
|
||||
|
||||
update_provider_stats(
|
||||
notification_id,
|
||||
SMS_TYPE,
|
||||
provider.get_name(),
|
||||
billable_units=notification.billable_units
|
||||
)
|
||||
|
||||
notification.sent_at = datetime.utcnow()
|
||||
notification.sent_by = provider.get_name()
|
||||
notification.status = 'sending'
|
||||
@@ -163,12 +155,6 @@ def send_email_to_provider(self, service_id, notification_id):
|
||||
reply_to_address=service.reply_to_email_address,
|
||||
)
|
||||
|
||||
update_provider_stats(
|
||||
notification_id,
|
||||
EMAIL_TYPE,
|
||||
provider.get_name(),
|
||||
billable_units=1
|
||||
)
|
||||
notification.reference = reference
|
||||
notification.sent_at = datetime.utcnow()
|
||||
notification.sent_by = provider.get_name(),
|
||||
|
||||
@@ -17,12 +17,9 @@ from app.models import (
|
||||
Notification,
|
||||
NotificationHistory,
|
||||
NotificationStatistics,
|
||||
TemplateStatistics,
|
||||
SMS_TYPE,
|
||||
EMAIL_TYPE,
|
||||
Template,
|
||||
ProviderStatistics,
|
||||
ProviderDetails)
|
||||
Template)
|
||||
from app.clients import (
|
||||
STATISTICS_FAILURE,
|
||||
STATISTICS_DELIVERED,
|
||||
@@ -242,33 +239,6 @@ def dao_update_notification(notification):
|
||||
db.session.commit()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
@transactional
|
||||
def update_provider_stats(
|
||||
id_,
|
||||
notification_type,
|
||||
provider_name,
|
||||
billable_units=1):
|
||||
notification = Notification.query.filter(Notification.id == id_).one()
|
||||
provider = ProviderDetails.query.filter_by(identifier=provider_name).one()
|
||||
|
||||
update_count = db.session.query(ProviderStatistics).filter_by(
|
||||
day=date.today(),
|
||||
service_id=notification.service_id,
|
||||
provider_id=provider.id
|
||||
).update({'unit_count': ProviderStatistics.unit_count + billable_units})
|
||||
|
||||
if update_count == 0:
|
||||
provider_stats = ProviderStatistics(
|
||||
day=notification.created_at.date(),
|
||||
service_id=notification.service_id,
|
||||
provider_id=provider.id,
|
||||
unit_count=billable_units
|
||||
)
|
||||
|
||||
db.session.add(provider_stats)
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def get_notification_for_job(service_id, job_id, notification_id):
|
||||
return Notification.query.filter_by(service_id=service_id, job_id=job_id, id=notification_id).one()
|
||||
|
||||
Reference in New Issue
Block a user