mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Merge pull request #2514 from alphagov/dont-insert-notification-history
Look for notification in both tables for complaints
This commit is contained in:
@@ -18,7 +18,6 @@ from requests import (
|
||||
RequestException
|
||||
)
|
||||
from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from app import (
|
||||
create_uuid,
|
||||
@@ -42,7 +41,6 @@ from app.dao.notifications_dao import (
|
||||
dao_get_last_notification_added_for_job_id,
|
||||
update_notification_status_by_reference,
|
||||
dao_get_notification_history_by_reference,
|
||||
dao_get_notification_by_reference,
|
||||
)
|
||||
from app.dao.provider_details_dao import get_current_provider
|
||||
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
|
||||
@@ -498,12 +496,7 @@ def update_letter_notification(filename, temporary_failures, update):
|
||||
|
||||
|
||||
def check_billable_units(notification_update):
|
||||
try:
|
||||
# This try except is necessary because in test keys and research mode does not create notification history.
|
||||
# Otherwise we could just search for the NotificationHistory object
|
||||
notification = dao_get_notification_by_reference(notification_update.reference)
|
||||
except NoResultFound:
|
||||
notification = dao_get_notification_history_by_reference(notification_update.reference)
|
||||
notification = dao_get_notification_history_by_reference(notification_update.reference)
|
||||
|
||||
if int(notification_update.page_count) != notification.billable_units:
|
||||
msg = 'Notification with id {} has {} billable_units but DVLA says page count is {}'.format(
|
||||
|
||||
@@ -17,6 +17,7 @@ from notifications_utils.statsd_decorators import statsd
|
||||
from notifications_utils.timezones import convert_utc_to_bst
|
||||
from sqlalchemy import (desc, func, asc)
|
||||
from sqlalchemy.orm import joinedload
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
from sqlalchemy.sql import functions
|
||||
from sqlalchemy.sql.expression import case
|
||||
from sqlalchemy.dialects.postgresql import insert
|
||||
@@ -585,9 +586,16 @@ def dao_get_notification_by_reference(reference):
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_notification_history_by_reference(reference):
|
||||
return NotificationHistory.query.filter(
|
||||
NotificationHistory.reference == reference
|
||||
).one()
|
||||
try:
|
||||
# This try except is necessary because in test keys and research mode does not create notification history.
|
||||
# Otherwise we could just search for the NotificationHistory object
|
||||
return Notification.query.filter(
|
||||
Notification.reference == reference
|
||||
).one()
|
||||
except NoResultFound:
|
||||
return NotificationHistory.query.filter(
|
||||
NotificationHistory.reference == reference
|
||||
).one()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
|
||||
Reference in New Issue
Block a user