mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 15:15:38 -05:00
Ignore services that have letters_as_pdf permission
- We don't want to process the letters as a build file for api calls when the service is generating letters as pdf.
This commit is contained in:
@@ -26,6 +26,8 @@ from app.models import (
|
||||
Notification,
|
||||
NotificationHistory,
|
||||
ScheduledNotification,
|
||||
Service,
|
||||
ServicePermission,
|
||||
Template,
|
||||
TemplateHistory,
|
||||
KEY_TYPE_NORMAL,
|
||||
@@ -541,14 +543,28 @@ def dao_set_created_live_letter_api_notifications_to_pending():
|
||||
this is used in the run_scheduled_jobs task, so we put a FOR UPDATE lock on the job table for the duration of
|
||||
the transaction so that if the task is run more than once concurrently, one task will block the other select
|
||||
from completing until it commits.
|
||||
|
||||
Note - do not process services that have letters_as_pdf permission as they
|
||||
will get processed when the letters PDF zip task is created
|
||||
"""
|
||||
|
||||
# Ignore services that have letters_as_pdf permission
|
||||
services_without_letters_as_pdf = [
|
||||
s.id for s in Service.query.filter(
|
||||
~Service.permissions.any(
|
||||
ServicePermission.permission == 'letters_as_pdf'
|
||||
)
|
||||
).all()
|
||||
]
|
||||
|
||||
notifications = db.session.query(
|
||||
Notification
|
||||
).filter(
|
||||
Notification.notification_type == LETTER_TYPE,
|
||||
Notification.status == NOTIFICATION_CREATED,
|
||||
Notification.key_type == KEY_TYPE_NORMAL,
|
||||
Notification.api_key != None # noqa
|
||||
Notification.api_key != None, # noqa
|
||||
Notification.service_id.in_(services_without_letters_as_pdf)
|
||||
).with_for_update(
|
||||
).all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user