mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-06 04:48:26 -04:00
Refactored to check trial when running scheduled job
This commit is contained in:
@@ -39,7 +39,7 @@ from app.notifications.process_notifications import send_notification_to_queue
|
||||
from app.statsd_decorators import statsd
|
||||
from app.celery.tasks import process_job
|
||||
from app.config import QueueNames, TaskNames
|
||||
from app.utils import convert_utc_to_bst
|
||||
from app.utils import convert_utc_to_bst, get_unrestricted_letter_ids
|
||||
|
||||
|
||||
@notify_celery.task(name="remove_csv_files")
|
||||
@@ -308,9 +308,14 @@ def populate_monthly_billing():
|
||||
@statsd(namespace="tasks")
|
||||
def run_letter_jobs():
|
||||
job_ids = dao_get_letter_job_ids_by_status(JOB_STATUS_READY_TO_SEND)
|
||||
notify_celery.send_task(
|
||||
name=TaskNames.DVLA_FILES,
|
||||
args=(job_ids,),
|
||||
queue=QueueNames.PROCESS_FTP
|
||||
)
|
||||
current_app.logger.info("Queued {} ready letter job ids onto {}".format(len(job_ids), QueueNames.PROCESS_FTP))
|
||||
|
||||
unrestricted_job_ids = get_unrestricted_letter_ids(job_ids)
|
||||
|
||||
if unrestricted_job_ids:
|
||||
notify_celery.send_task(
|
||||
name=TaskNames.DVLA_FILES,
|
||||
args=(unrestricted_job_ids,),
|
||||
queue=QueueNames.PROCESS_FTP
|
||||
)
|
||||
current_app.logger.info(
|
||||
"Queued {} ready letter job ids onto {}".format(len(unrestricted_job_ids), QueueNames.PROCESS_FTP))
|
||||
|
||||
@@ -75,7 +75,7 @@ def process_job(job_id):
|
||||
|
||||
db_template = dao_get_template_by_id(job.template_id, job.template_version)
|
||||
|
||||
if db_template.template_type == LETTER_TYPE and service.restricted:
|
||||
if db_template.template_type == LETTER_TYPE and job.service.restricted:
|
||||
job.job_status = JOB_STATUS_ERROR
|
||||
dao_update_job(job)
|
||||
current_app.logger.warn(
|
||||
@@ -97,9 +97,9 @@ def process_job(job_id):
|
||||
update_job_to_sent_to_dvla.apply_async([str(job.id)], queue=QueueNames.RESEARCH_MODE)
|
||||
else:
|
||||
build_dvla_file.apply_async([str(job.id)], queue=QueueNames.JOBS)
|
||||
# temporary logging
|
||||
current_app.logger.info("send job {} to build-dvla-file in the {} queue".format(
|
||||
job_id, QueueNames.JOBS if not service.research_mode else QueueNames.RESEARCH_MODE))
|
||||
# temporary logging
|
||||
current_app.logger.info("send job {} to build-dvla-file in the {} queue".format(
|
||||
job_id, QueueNames.JOBS))
|
||||
else:
|
||||
job.job_status = JOB_STATUS_FINISHED
|
||||
|
||||
|
||||
Reference in New Issue
Block a user