mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-19 14:08:47 -04:00
remove get-pdf-for-templated-letter
This commit is contained in:
@@ -55,51 +55,6 @@ from app.models import (
|
||||
)
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name="get-pdf-for-templated-letter", max_retries=15, default_retry_delay=300)
|
||||
def get_pdf_for_templated_letter(self, notification_id):
|
||||
try:
|
||||
notification = get_notification_by_id(notification_id, _raise=True)
|
||||
letter_filename = generate_letter_pdf_filename(
|
||||
reference=notification.reference,
|
||||
created_at=notification.created_at,
|
||||
ignore_folder=notification.key_type == KEY_TYPE_TEST,
|
||||
postage=notification.postage
|
||||
)
|
||||
letter_data = {
|
||||
'letter_contact_block': notification.reply_to_text,
|
||||
'template': {
|
||||
"subject": notification.template.subject,
|
||||
"content": notification.template.content,
|
||||
"template_type": notification.template.template_type
|
||||
},
|
||||
'values': notification.personalisation,
|
||||
'logo_filename': notification.service.letter_branding and notification.service.letter_branding.filename,
|
||||
'letter_filename': letter_filename,
|
||||
"notification_id": str(notification_id),
|
||||
'key_type': notification.key_type
|
||||
}
|
||||
|
||||
encrypted_data = encryption.encrypt(letter_data)
|
||||
|
||||
notify_celery.send_task(
|
||||
name=TaskNames.CREATE_PDF_FOR_TEMPLATED_LETTER,
|
||||
args=(encrypted_data,),
|
||||
queue=QueueNames.SANITISE_LETTERS
|
||||
)
|
||||
except Exception as e:
|
||||
try:
|
||||
current_app.logger.exception(
|
||||
f"RETRY: calling create-letter-pdf task for notification {notification_id} failed"
|
||||
)
|
||||
self.retry(exc=e, queue=QueueNames.RETRY)
|
||||
except self.MaxRetriesExceededError:
|
||||
message = f"RETRY FAILED: Max retries reached. " \
|
||||
f"The task create-letter-pdf failed for notification id {notification_id}. " \
|
||||
f"Notification has been updated to technical-failure"
|
||||
update_notification_status_by_id(notification_id, NOTIFICATION_TECHNICAL_FAILURE)
|
||||
raise NotificationTechnicalFailureException(message)
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name="update-billable-units-for-letter", max_retries=15, default_retry_delay=300)
|
||||
def update_billable_units_for_letter(self, notification_id, page_count):
|
||||
notification = get_notification_by_id(notification_id, _raise=True)
|
||||
|
||||
@@ -9,7 +9,6 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
|
||||
from app import notify_celery, zendesk_client
|
||||
from app.aws import s3
|
||||
from app.celery.letters_pdf_tasks import get_pdf_for_templated_letter
|
||||
from app.celery.tasks import (
|
||||
get_recipient_csv_and_template_and_sender_id,
|
||||
process_incomplete_jobs,
|
||||
@@ -165,20 +164,6 @@ def replay_created_notifications():
|
||||
for n in notifications_to_resend:
|
||||
send_notification_to_queue(notification=n, research_mode=n.service.research_mode)
|
||||
|
||||
# if the letter has not be send after an hour, then create a zendesk ticket
|
||||
letters = letters_missing_from_sending_bucket(resend_created_notifications_older_than)
|
||||
|
||||
if len(letters) > 0:
|
||||
msg = "{} letters were created over an hour ago, " \
|
||||
"but do not have an updated_at timestamp or billable units. " \
|
||||
"\n Creating app.celery.letters_pdf_tasks.create_letters tasks to upload letter to S3 " \
|
||||
"and update notifications for the following notification ids: " \
|
||||
"\n {}".format(len(letters), [x.id for x in letters])
|
||||
|
||||
current_app.logger.info(msg)
|
||||
for letter in letters:
|
||||
get_pdf_for_templated_letter.apply_async([str(letter.id)], queue=QueueNames.CREATE_LETTERS_PDF)
|
||||
|
||||
|
||||
@notify_celery.task(name='check-for-missing-rows-in-completed-jobs')
|
||||
def check_for_missing_rows_in_completed_jobs():
|
||||
|
||||
@@ -385,12 +385,7 @@ def save_letter(
|
||||
status=status
|
||||
)
|
||||
|
||||
if not service.research_mode:
|
||||
letters_pdf_tasks.get_pdf_for_templated_letter.apply_async(
|
||||
[str(saved_notification.id)],
|
||||
queue=QueueNames.CREATE_LETTERS_PDF
|
||||
)
|
||||
elif current_app.config['NOTIFY_ENVIRONMENT'] in ['preview', 'development']:
|
||||
if current_app.config['NOTIFY_ENVIRONMENT'] in ['preview', 'development']:
|
||||
research_mode_tasks.create_fake_letter_response_file.apply_async(
|
||||
(saved_notification.reference,),
|
||||
queue=QueueNames.RESEARCH_MODE
|
||||
|
||||
Reference in New Issue
Block a user