mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Add updated history count to dao_update_notifications_by_reference
For returned letter updates most notifications won't exist in the notifications table, so in order to find out whether the reference matches any known letters we need to check the count of updated history records.
This commit is contained in:
@@ -288,7 +288,7 @@ def update_letter_pdf_status(reference, status):
|
||||
update_dict={
|
||||
'status': status,
|
||||
'updated_at': datetime.utcnow()
|
||||
})
|
||||
})[0]
|
||||
|
||||
|
||||
def replay_letters_in_error(filename=None):
|
||||
|
||||
@@ -339,7 +339,7 @@ def update_letter_notifications_to_sent_to_dvla(self, notification_references):
|
||||
# This task will be called by the FTP app to update notifications as sent to DVLA
|
||||
provider = get_current_provider(LETTER_TYPE)
|
||||
|
||||
updated_count = dao_update_notifications_by_reference(
|
||||
updated_count, _ = dao_update_notifications_by_reference(
|
||||
notification_references,
|
||||
{
|
||||
'status': NOTIFICATION_SENDING,
|
||||
@@ -357,7 +357,7 @@ def update_letter_notifications_to_sent_to_dvla(self, notification_references):
|
||||
def update_letter_notifications_to_error(self, notification_references):
|
||||
# This task will be called by the FTP app to update notifications as sent to DVLA
|
||||
|
||||
updated_count = dao_update_notifications_by_reference(
|
||||
updated_count, _ = dao_update_notifications_by_reference(
|
||||
notification_references,
|
||||
{
|
||||
'status': NOTIFICATION_TECHNICAL_FAILURE,
|
||||
@@ -465,7 +465,7 @@ def update_letter_notification(filename, temporary_failures, update):
|
||||
status = NOTIFICATION_TEMPORARY_FAILURE
|
||||
temporary_failures.append(update.reference)
|
||||
|
||||
updated_count = dao_update_notifications_by_reference(
|
||||
updated_count, _ = dao_update_notifications_by_reference(
|
||||
references=[update.reference],
|
||||
update_dict={"status": status,
|
||||
"billable_units": update.page_count,
|
||||
|
||||
@@ -465,14 +465,14 @@ def dao_update_notifications_by_reference(references, update_dict):
|
||||
synchronize_session=False
|
||||
)
|
||||
|
||||
NotificationHistory.query.filter(
|
||||
updated_history_count = NotificationHistory.query.filter(
|
||||
NotificationHistory.reference.in_(references)
|
||||
).update(
|
||||
update_dict,
|
||||
synchronize_session=False
|
||||
)
|
||||
|
||||
return updated_count
|
||||
return updated_count, updated_history_count
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
|
||||
Reference in New Issue
Block a user