mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 09:26:08 -05:00
'detailed' flag on GET /service/<uuid>
if passed in, returns the service object with additional statistics dictionary, which will be used in the admin app to populate dashboard components. A new schema has been created for this to avoid clashing/ causing confusion with the existing schema, which is already used for PUT/POST as well, and this schema can be easily tailored to reduce ambiguity and lazy-loading
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
import uuid
|
||||
|
||||
from app import db
|
||||
from app.models import Service
|
||||
from sqlalchemy import asc
|
||||
from sqlalchemy import asc, func
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from app import db
|
||||
from app.dao.dao_utils import (
|
||||
transactional,
|
||||
version_class
|
||||
)
|
||||
|
||||
from app.models import (
|
||||
NotificationStatistics,
|
||||
TemplateStatistics,
|
||||
@@ -135,3 +133,16 @@ def delete_service_and_all_associated_db_objects(service):
|
||||
db.session.commit()
|
||||
list(map(db.session.delete, users))
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def dao_fetch_stats_for_service(service_id):
|
||||
return db.session.query(
|
||||
Notification.notification_type,
|
||||
Notification.status,
|
||||
func.count(Notification.id).label('count')
|
||||
).filter(
|
||||
Notification.service_id == service_id
|
||||
).group_by(
|
||||
Notification.notification_type,
|
||||
Notification.status,
|
||||
).all()
|
||||
|
||||
Reference in New Issue
Block a user