diff --git a/app/celery/scheduled_tasks.py b/app/celery/scheduled_tasks.py index 57b890f39..3597bdbb7 100644 --- a/app/celery/scheduled_tasks.py +++ b/app/celery/scheduled_tasks.py @@ -1,10 +1,10 @@ from datetime import timedelta from flask import current_app -from sqlalchemy import between, select +from sqlalchemy import between from sqlalchemy.exc import SQLAlchemyError -from app import db, notify_celery, zendesk_client +from app import notify_celery, zendesk_client from app.celery.tasks import ( get_recipient_csv_and_template_and_sender_id, process_incomplete_jobs, @@ -105,28 +105,14 @@ def check_job_status(): thirty_minutes_ago = utc_now() - timedelta(minutes=30) thirty_five_minutes_ago = utc_now() - timedelta(minutes=35) - incomplete_in_progress_jobs = ( - db.session.execute( - select(Job).where( - Job.job_status == JobStatus.IN_PROGRESS, - between( - Job.processing_started, thirty_five_minutes_ago, thirty_minutes_ago - ), - ) - ) - .scalars() - .all() + incomplete_in_progress_jobs = Job.query.filter( + Job.job_status == JobStatus.IN_PROGRESS, + between(Job.processing_started, thirty_five_minutes_ago, thirty_minutes_ago), ) - incomplete_pending_jobs = ( - db.session.execute( - select(Job).where( - Job.job_status == JobStatus.PENDING, - Job.scheduled_for.isnot(None), - between(Job.scheduled_for, thirty_five_minutes_ago, thirty_minutes_ago), - ) - ) - .scalars() - .all() + incomplete_pending_jobs = Job.query.filter( + Job.job_status == JobStatus.PENDING, + Job.scheduled_for.isnot(None), + between(Job.scheduled_for, thirty_five_minutes_ago, thirty_minutes_ago), ) jobs_not_complete_after_30_minutes = ( diff --git a/tests/app/dao/test_service_inbound_api_dao.py b/tests/app/dao/test_service_inbound_api_dao.py index 03eb6d616..232d256dd 100644 --- a/tests/app/dao/test_service_inbound_api_dao.py +++ b/tests/app/dao/test_service_inbound_api_dao.py @@ -37,8 +37,9 @@ def test_save_service_inbound_api(sample_service): assert inbound_api.updated_at is None versioned = ( - db.session.execute(select(ServiceInboundApi.get_history_model())) - .filter_by(id=inbound_api.id) + db.session.execute( + select(ServiceInboundApi.get_history_model()).filter_by(id=inbound_api.id) + ) .scalars() .one() ) @@ -94,9 +95,9 @@ def test_update_service_inbound_api(sample_service): versioned_results = ( db.session.execute( - select(ServiceInboundApi) - .get_history_model() - .filter_by(id=saved_inbound_api.id) + select(ServiceInboundApi.get_history_model()).filter_by( + id=saved_inbound_api.id + ) ) .scalars() .all()