mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Refactored notifications_dao
- Introduce a `_raise` flag for `get_notification_by_id` so that sql alchemy will raise the NoResults error rather than the app - Refactor `dao_set_created_live_letter_api_notifications_to_pending` to use a join for getting services that don't have `letters_as_pdf` as marginally faster.
This commit is contained in:
@@ -5,7 +5,6 @@ from requests import (
|
||||
)
|
||||
|
||||
from botocore.exceptions import ClientError as BotoClientError
|
||||
from sqlalchemy.orm.exc import NoResultFound
|
||||
|
||||
from app import notify_celery
|
||||
from app.aws import s3
|
||||
@@ -18,9 +17,7 @@ from app.statsd_decorators import statsd
|
||||
@statsd(namespace="tasks")
|
||||
def create_letters_pdf(self, notification_id):
|
||||
try:
|
||||
notification = get_notification_by_id(notification_id)
|
||||
if not notification:
|
||||
raise NoResultFound()
|
||||
notification = get_notification_by_id(notification_id, _raise=True)
|
||||
|
||||
pdf_data = get_letters_pdf(
|
||||
notification.template,
|
||||
|
||||
Reference in New Issue
Block a user