mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Remove all methods no longer used now that we only send pdf files to DVLA.
This commit is contained in:
@@ -3,14 +3,24 @@ from datetime import datetime, timedelta
|
||||
|
||||
from flask import current_app
|
||||
from notifications_utils.statsd_decorators import statsd
|
||||
from sqlalchemy import func, desc, asc, cast, Date as sql_date
|
||||
from sqlalchemy import (
|
||||
Date as sql_date,
|
||||
asc,
|
||||
cast,
|
||||
desc,
|
||||
func,
|
||||
)
|
||||
|
||||
from app import db
|
||||
from app.dao import days_ago
|
||||
from app.models import (
|
||||
Job, JobStatistics, Notification, NotificationHistory, Template,
|
||||
JOB_STATUS_SCHEDULED, JOB_STATUS_PENDING,
|
||||
LETTER_TYPE
|
||||
Job,
|
||||
JobStatistics,
|
||||
JOB_STATUS_PENDING,
|
||||
JOB_STATUS_SCHEDULED,
|
||||
LETTER_TYPE,
|
||||
NotificationHistory,
|
||||
Template,
|
||||
)
|
||||
from app.variables import LETTER_TEST_API_FILENAME
|
||||
|
||||
@@ -22,28 +32,15 @@ def dao_get_notification_outcomes_for_job(service_id, job_id):
|
||||
NotificationHistory.status
|
||||
)
|
||||
|
||||
return query \
|
||||
.filter(NotificationHistory.service_id == service_id) \
|
||||
.filter(NotificationHistory.job_id == job_id)\
|
||||
.group_by(NotificationHistory.status) \
|
||||
.order_by(asc(NotificationHistory.status)) \
|
||||
.all()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def all_notifications_are_created_for_job(job_id):
|
||||
query = db.session.query(func.count(Notification.id), Job.id)\
|
||||
.join(Job)\
|
||||
.filter(Job.id == job_id)\
|
||||
.group_by(Job.id)\
|
||||
.having(func.count(Notification.id) == Job.notification_count).all()
|
||||
|
||||
return query
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_all_notifications_for_job(job_id):
|
||||
return db.session.query(Notification).filter(Notification.job_id == job_id).order_by(Notification.created_at).all()
|
||||
return query.filter(
|
||||
NotificationHistory.service_id == service_id
|
||||
).filter(
|
||||
NotificationHistory.job_id == job_id
|
||||
).group_by(
|
||||
NotificationHistory.status
|
||||
).order_by(
|
||||
asc(NotificationHistory.status)
|
||||
).all()
|
||||
|
||||
|
||||
def dao_get_job_by_service_id_and_job_id(service_id, job_id):
|
||||
|
||||
@@ -28,7 +28,6 @@ from app.models import (
|
||||
NotificationHistory,
|
||||
ScheduledNotification,
|
||||
Service,
|
||||
ServicePermission,
|
||||
Template,
|
||||
TemplateHistory,
|
||||
KEY_TYPE_NORMAL,
|
||||
@@ -547,42 +546,6 @@ def dao_get_total_notifications_sent_per_day_for_performance_platform(start_date
|
||||
).one()
|
||||
|
||||
|
||||
def dao_set_created_live_letter_api_notifications_to_pending():
|
||||
"""
|
||||
Sets all past scheduled jobs to pending, and then returns them for further processing.
|
||||
|
||||
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
|
||||
"""
|
||||
notifications = db.session.query(
|
||||
Notification
|
||||
).join(
|
||||
Service
|
||||
).filter(
|
||||
Notification.notification_type == LETTER_TYPE,
|
||||
Notification.status == NOTIFICATION_CREATED,
|
||||
Notification.key_type == KEY_TYPE_NORMAL,
|
||||
Notification.api_key != None, # noqa
|
||||
# Ignore services that have letters_as_pdf permission
|
||||
~Service.permissions.any(
|
||||
ServicePermission.permission == 'letters_as_pdf'
|
||||
)
|
||||
).with_for_update(
|
||||
).all()
|
||||
|
||||
for notification in notifications:
|
||||
notification.status = NOTIFICATION_PENDING
|
||||
|
||||
db.session.add_all(notifications)
|
||||
db.session.commit()
|
||||
|
||||
return notifications
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_last_notification_added_for_job_id(job_id):
|
||||
last_notification_added = Notification.query.filter(
|
||||
|
||||
Reference in New Issue
Block a user