mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Build rest endpoint to read service stats
- get stats by service id - returns a list of stats objects Not paginated - have 1 row per day.
This commit is contained in:
25
app/notifications_statistics/rest.py
Normal file
25
app/notifications_statistics/rest.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from flask import (
|
||||
Blueprint,
|
||||
jsonify,
|
||||
)
|
||||
|
||||
from app.dao.notifications_dao import (
|
||||
dao_get_notification_statistics_for_service
|
||||
)
|
||||
from app.schemas import notifications_statistics_schema
|
||||
|
||||
notifications_statistics = Blueprint(
|
||||
'notifications-statistics',
|
||||
__name__, url_prefix='/service/<service_id>/notifications-statistics'
|
||||
)
|
||||
|
||||
from app.errors import register_errors
|
||||
|
||||
register_errors(notifications_statistics)
|
||||
|
||||
|
||||
@notifications_statistics.route('', methods=['GET'])
|
||||
def get_all_templates_for_service(service_id):
|
||||
templates = dao_get_notification_statistics_for_service(service_id=service_id)
|
||||
data, errors = notifications_statistics_schema.dump(templates, many=True)
|
||||
return jsonify(data=data)
|
||||
Reference in New Issue
Block a user