Merge pull request #1248 from GSA/notify-apy-283

Need to remove priority logic
This commit is contained in:
Cliff Hill
2024-08-16 12:36:55 -04:00
committed by GitHub
14 changed files with 36 additions and 214 deletions

View File

@@ -11,7 +11,6 @@ from app.cloudfoundry_config import cloud_config
class QueueNames(object):
PERIODIC = "periodic-tasks"
PRIORITY = "priority-tasks"
DATABASE = "database-tasks"
SEND_SMS = "send-sms-tasks"
CHECK_SMS = "check-sms_tasks"
@@ -30,7 +29,6 @@ class QueueNames(object):
@staticmethod
def all_queues():
return [
QueueNames.PRIORITY,
QueueNames.PERIODIC,
QueueNames.DATABASE,
QueueNames.SEND_SMS,

View File

@@ -1,7 +1,7 @@
from datetime import datetime
from flask import current_app
from sqlalchemy import asc, desc, func
from sqlalchemy import desc, func
from app import db
from app.dao.dao_utils import autocommit
@@ -33,20 +33,6 @@ def dao_get_provider_versions(provider_id):
)
def _adjust_provider_priority(provider, new_priority):
current_app.logger.info(
f"Adjusting provider priority - {provider.identifier} going from {provider.priority} to {new_priority}"
)
provider.priority = new_priority
# Automatic update so set as notify user
provider.created_by_id = current_app.config["NOTIFY_USER_ID"]
# update without commit so that both rows can be changed without ending the transaction
# and releasing the for_update lock
_update_provider_details_without_commit(provider)
def _get_sms_providers_for_update(time_threshold):
"""
Returns a list of providers, while holding a for_update lock on the provider details table, guaranteeing that those
@@ -86,11 +72,7 @@ def get_provider_details_by_notification_type(
if supports_international:
filters.append(ProviderDetails.supports_international == supports_international)
return (
ProviderDetails.query.filter(*filters)
.order_by(asc(ProviderDetails.priority))
.all()
)
return ProviderDetails.query.filter(*filters).all()
@autocommit
@@ -135,7 +117,6 @@ def dao_get_provider_stats():
ProviderDetails.id,
ProviderDetails.display_name,
ProviderDetails.identifier,
ProviderDetails.priority,
ProviderDetails.notification_type,
ProviderDetails.active,
ProviderDetails.updated_at,
@@ -149,7 +130,6 @@ def dao_get_provider_stats():
.outerjoin(User, ProviderDetails.created_by_id == User.id)
.order_by(
ProviderDetails.notification_type,
ProviderDetails.priority,
)
.all()
)

View File

@@ -1297,7 +1297,6 @@ class ProviderDetails(db.Model):
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
display_name = db.Column(db.String, nullable=False)
identifier = db.Column(db.String, nullable=False)
priority = db.Column(db.Integer, nullable=False)
notification_type = enum_column(NotificationType, nullable=False)
active = db.Column(db.Boolean, default=False, nullable=False)
version = db.Column(db.Integer, default=1, nullable=False)
@@ -1322,7 +1321,6 @@ class ProviderDetailsHistory(db.Model, HistoryModel):
id = db.Column(UUID(as_uuid=True), primary_key=True, nullable=False)
display_name = db.Column(db.String, nullable=False)
identifier = db.Column(db.String, nullable=False)
priority = db.Column(db.Integer, nullable=False)
notification_type = enum_column(NotificationType, nullable=False)
active = db.Column(db.Boolean, nullable=False)
version = db.Column(db.Integer, primary_key=True, nullable=False)

View File

@@ -2,9 +2,8 @@ from flask import Blueprint, current_app, jsonify, request
from app import api_user, authenticated_service
from app.aws.s3 import get_personalisation_from_s3, get_phone_number_from_s3
from app.config import QueueNames
from app.dao import notifications_dao
from app.enums import KeyType, NotificationType, TemplateProcessType
from app.enums import KeyType, NotificationType
from app.errors import InvalidRequest, register_errors
from app.notifications.process_notifications import (
persist_notification,
@@ -168,11 +167,7 @@ def send_notification(notification_type):
reply_to_text=template.reply_to_text,
)
if not simulated:
queue_name = (
QueueNames.PRIORITY
if template.process_type == TemplateProcessType.PRIORITY
else None
)
queue_name = None
send_notification_to_queue(notification=notification_model, queue=queue_name)
else:

View File

@@ -23,7 +23,6 @@ def get_providers():
"id": row.id,
"display_name": row.display_name,
"identifier": row.identifier,
"priority": row.priority,
"notification_type": row.notification_type,
"active": row.active,
"updated_at": row.updated_at,

View File

@@ -1,12 +1,11 @@
from sqlalchemy.orm.exc import NoResultFound
from app.config import QueueNames
from app.dao.service_email_reply_to_dao import dao_get_reply_to_by_id
from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
from app.dao.services_dao import dao_fetch_service_by_id
from app.dao.templates_dao import dao_get_template_by_id_and_service_id
from app.dao.users_dao import get_user_by_id
from app.enums import KeyType, NotificationType, TemplateProcessType
from app.enums import KeyType, NotificationType
from app.errors import BadRequestError
from app.notifications.process_notifications import (
persist_notification,
@@ -80,11 +79,7 @@ def send_one_off_notification(service_id, post_data):
client_reference=client_reference,
)
queue_name = (
QueueNames.PRIORITY
if template.process_type == TemplateProcessType.PRIORITY
else None
)
queue_name = None
send_notification_to_queue(
notification=notification,

View File

@@ -8,7 +8,7 @@ from app import api_user, authenticated_service, document_download_client, encry
from app.celery.tasks import save_api_email, save_api_sms
from app.clients.document_download import DocumentDownloadError
from app.config import QueueNames
from app.enums import KeyType, NotificationStatus, NotificationType, TemplateProcessType
from app.enums import KeyType, NotificationStatus, NotificationType
from app.models import Notification
from app.notifications.process_notifications import (
persist_notification,
@@ -85,7 +85,6 @@ def process_sms_or_email_notification(
notification_type,
template,
template_with_content,
template_process_type,
service,
reply_to_text=None,
):
@@ -176,11 +175,7 @@ def process_sms_or_email_notification(
)
if not simulated:
queue_name = (
QueueNames.PRIORITY
if template_process_type == TemplateProcessType.PRIORITY
else None
)
queue_name = None
send_notification_to_queue_detached(
key_type=api_user.key_type,
notification_type=notification_type,