mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-05 16:48:31 -04:00
Delete unused aggregate_statistics endpoint
`@service_blueprint.route('/<uuid:service_id>/fragment/aggregate_statistics')`
is not being used anywhere, so has been removed. The `provider_statistics_dao`
can also be removed, since the function this contained was only used for
the endpoint.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
from sqlalchemy import func
|
||||
|
||||
from app import db
|
||||
from app.dao.date_util import get_financial_year
|
||||
from app.models import (
|
||||
NotificationHistory,
|
||||
SMS_TYPE,
|
||||
EMAIL_TYPE,
|
||||
NOTIFICATION_STATUS_TYPES_BILLABLE,
|
||||
KEY_TYPE_TEST
|
||||
)
|
||||
|
||||
|
||||
def get_fragment_count(service_id, year=None):
|
||||
shared_filters = [
|
||||
NotificationHistory.service_id == service_id,
|
||||
NotificationHistory.status.in_(NOTIFICATION_STATUS_TYPES_BILLABLE),
|
||||
NotificationHistory.key_type != KEY_TYPE_TEST
|
||||
]
|
||||
|
||||
if year:
|
||||
shared_filters.append(NotificationHistory.created_at.between(
|
||||
*get_financial_year(year)
|
||||
))
|
||||
|
||||
sms_count = db.session.query(
|
||||
func.sum(NotificationHistory.billable_units)
|
||||
).filter(
|
||||
NotificationHistory.notification_type == SMS_TYPE,
|
||||
*shared_filters
|
||||
)
|
||||
|
||||
email_count = db.session.query(
|
||||
func.count(NotificationHistory.id)
|
||||
).filter(
|
||||
NotificationHistory.notification_type == EMAIL_TYPE,
|
||||
*shared_filters
|
||||
)
|
||||
return {
|
||||
'sms_count': int(sms_count.scalar() or 0),
|
||||
'email_count': email_count.scalar() or 0
|
||||
}
|
||||
@@ -65,7 +65,6 @@ from app.dao.service_letter_contact_dao import (
|
||||
add_letter_contact_for_service,
|
||||
update_letter_contact
|
||||
)
|
||||
from app.dao.provider_statistics_dao import get_fragment_count
|
||||
from app.dao.users_dao import get_user_by_id
|
||||
from app.errors import (
|
||||
InvalidRequest,
|
||||
@@ -299,17 +298,6 @@ def remove_user_from_service(service_id, user_id):
|
||||
return jsonify({}), 204
|
||||
|
||||
|
||||
@service_blueprint.route('/<uuid:service_id>/fragment/aggregate_statistics')
|
||||
def get_service_provider_aggregate_statistics(service_id):
|
||||
year = request.args.get('year')
|
||||
if year is not None:
|
||||
try:
|
||||
year = int(year)
|
||||
except ValueError:
|
||||
raise InvalidRequest('Year must be a number', status_code=400)
|
||||
return jsonify(data=get_fragment_count(service_id, year=year))
|
||||
|
||||
|
||||
# This is placeholder get method until more thought
|
||||
# goes into how we want to fetch and view various items in history
|
||||
# tables. This is so product owner can pass stories as done
|
||||
|
||||
Reference in New Issue
Block a user