mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
add template_statistics endpoint for specific template
`/service/<service_id>/template-statistics/<template_id>` still requires service-id just to try and keep api tree cleaner
This commit is contained in:
@@ -5,7 +5,10 @@ from flask import (
|
||||
current_app
|
||||
)
|
||||
|
||||
from app.dao.notifications_dao import dao_get_template_statistics_for_service
|
||||
from app.dao.notifications_dao import (
|
||||
dao_get_template_statistics_for_service,
|
||||
dao_get_template_statistics_for_template
|
||||
)
|
||||
|
||||
from app.schemas import template_statistics_schema
|
||||
|
||||
@@ -34,3 +37,12 @@ def get_template_statistics_for_service(service_id):
|
||||
if errors:
|
||||
return jsonify(result="error", message=errors), 400
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
@template_statistics.route('/<template_id>')
|
||||
def get_template_statistics_for_template_id(service_id, template_id):
|
||||
stats = dao_get_template_statistics_for_template(template_id)
|
||||
data, errors = template_statistics_schema.dump(stats, many=True)
|
||||
if errors:
|
||||
return jsonify(result="error", message=errors), 400
|
||||
return jsonify(data=data)
|
||||
|
||||
Reference in New Issue
Block a user