mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-11 09:27:56 -04:00
Remove unused methods.
A new endpoint to return the last date a template was used which means the old endpoint can be removed.
This commit is contained in:
@@ -56,21 +56,6 @@ from app.utils import get_london_midnight_in_utc
|
||||
from app.utils import midnight_n_days_ago, escape_special_characters
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_last_template_usage(template_id, template_type, service_id):
|
||||
# By adding the service_id to the filter the performance of the query is greatly improved.
|
||||
# Using a max(Notification.created_at) is better than order by and limit one.
|
||||
# But the effort to change the endpoint to return a datetime only is more than the gain.
|
||||
return Notification.query.filter(
|
||||
Notification.template_id == template_id,
|
||||
Notification.key_type != KEY_TYPE_TEST,
|
||||
Notification.notification_type == template_type,
|
||||
Notification.service_id == service_id
|
||||
).order_by(
|
||||
desc(Notification.created_at)
|
||||
).first()
|
||||
|
||||
|
||||
@statsd(namespace="dao")
|
||||
def dao_get_last_date_template_was_used(template_id, service_id):
|
||||
last_date_from_notifications = db.session.query(
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from app import DATETIME_FORMAT
|
||||
from app.dao.notifications_dao import dao_get_last_template_usage, dao_get_last_date_template_was_used
|
||||
from app.dao.notifications_dao import dao_get_last_date_template_was_used
|
||||
from app.dao.templates_dao import dao_get_template_by_id_and_service_id
|
||||
from app.dao.fact_notification_status_dao import fetch_notification_status_for_service_for_today_and_7_previous_days
|
||||
|
||||
from app.schemas import notification_with_template_schema
|
||||
from app.errors import register_errors, InvalidRequest
|
||||
|
||||
template_statistics = Blueprint('template_statistics',
|
||||
@@ -44,18 +43,6 @@ def get_template_statistics_for_service_by_day(service_id):
|
||||
])
|
||||
|
||||
|
||||
@template_statistics.route('/<template_id>')
|
||||
def get_template_statistics_for_template_id(service_id, template_id):
|
||||
template = dao_get_template_by_id_and_service_id(template_id, service_id)
|
||||
|
||||
data = None
|
||||
notification = dao_get_last_template_usage(template_id, template.template_type, template.service_id)
|
||||
if notification:
|
||||
data = notification_with_template_schema.dump(notification).data
|
||||
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
@template_statistics.route('/last-used/<uuid:template_id>')
|
||||
def get_last_used_datetime_for_template(service_id, template_id):
|
||||
# Check the template and service exist
|
||||
|
||||
Reference in New Issue
Block a user