From bc8ac8b2d9d743ee0674d81ab61178f1071bed12 Mon Sep 17 00:00:00 2001 From: Stephen Astels Date: Tue, 28 Sep 2021 15:51:48 -0400 Subject: [PATCH] meh, lets leave that for another time --- app/__init__.py | 3 +- app/dao/notifications_dao.py | 12 -------- app/support/rest.py | 57 +++++++++++------------------------- 3 files changed, 18 insertions(+), 54 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index b761b766e5..83ddcef847 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -199,8 +199,7 @@ def register_blueprint(application): letter_branding_blueprint.before_request(requires_admin_auth) application.register_blueprint(letter_branding_blueprint) - # support_blueprint.before_request(requires_admin_auth) - support_blueprint.before_request(requires_no_auth) + support_blueprint.before_request(requires_admin_auth) application.register_blueprint(support_blueprint, url_prefix="/support") diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index c851e62c82..f0598b7b97 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -192,18 +192,6 @@ def get_notification_by_id(notification_id, service_id=None, _raise=False): return query.one() if _raise else query.first() -@statsd(namespace="dao") -def get_notification_history_by_id(notification_history_id, service_id=None, _raise=False): - filters = [NotificationHistory.id == notification_history_id] - - if service_id: - filters.append(NotificationHistory.service_id == service_id) - - query = db.on_reader().query(NotificationHistory).filter(*filters) - - return query.one() if _raise else query.first() - - def get_notifications(filter_dict=None): return _filter_query(Notification.query, filter_dict=filter_dict) diff --git a/app/support/rest.py b/app/support/rest.py index 19d42e0ec5..2ebda7a3cf 100644 --- a/app/support/rest.py +++ b/app/support/rest.py @@ -2,12 +2,11 @@ from sqlalchemy.orm.exc import NoResultFound from app.dao.jobs_dao import dao_get_job_by_id -from app.dao.notifications_dao import get_notification_by_id, get_notification_history_by_id +from app.dao.notifications_dao import get_notification_by_id from app.dao.services_dao import dao_fetch_service_by_id from app.dao.templates_dao import dao_get_template_by_id from app.dao.users_dao import get_user_by_id from app.errors import register_errors -from flask import current_app support_blueprint = Blueprint("support", __name__) register_errors(support_blueprint) @@ -35,33 +34,10 @@ def notification_query(id): pass -def notification_history_query(id): - try: - notification = get_notification_history_by_id(id) - if notification: - return { - "type": "notification_history", - "id": notification.id, - "notification_type": notification.notification_type, - "status": notification.status, - "created_at": notification.created_at, - "sent_at": notification.sent_at, - "to": "expired", - "service_id": notification.service_id, - "service_name": notification.service.name, - "job_id": notification.job_id, - "job_row_number": notification.job_row_number, - "api_key_id": notification.api_key_id, - } - except NoResultFound: - pass - - def template_query(id): try: template = dao_get_template_by_id(id) if template: - return { "type": "template", "id": template.id, @@ -85,20 +61,21 @@ def service_query(id): def job_query(id): try: job = dao_get_job_by_id(id) - return { - "type": "job", - "id": job.id, - "original_file_name": job.original_file_name, - "created_at": job.created_at, - "created_by_id": job.created_by_id, - "created_by_name": job.created_by.name, - "processing_started": job.processing_started, - "processing_finished": job.processing_finished, - "notification_count": job.notification_count, - "job_status": job.job_status, - "service_id": job.service_id, - "service_name": job.service.name, - } + if job: + return { + "type": "job", + "id": job.id, + "original_file_name": job.original_file_name, + "created_at": job.created_at, + "created_by_id": job.created_by_id, + "created_by_name": job.created_by.name, + "processing_started": job.processing_started, + "processing_finished": job.processing_finished, + "notification_count": job.notification_count, + "job_status": job.job_status, + "service_id": job.service_id, + "service_name": job.service.name, + } except NoResultFound: pass @@ -120,7 +97,7 @@ def user_query(id): @support_blueprint.route("/", methods=["GET"]) def get_id_info(id): - for query_func in [user_query, service_query, template_query, job_query, notification_query, notification_history_query]: + for query_func in [user_query, service_query, template_query, job_query, notification_query]: results = query_func(id) if results: return jsonify(results)