mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Update the organsition usage endpoint to use the new query.
This endpoint may need to change, but we'd like to see how this performs, so we'll test this with a real data set. Then come back to make sure the format is correct and check for missing tests for the endpoint,
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
from datetime import datetime
|
||||
|
||||
from flask import abort, Blueprint, jsonify, request, current_app
|
||||
from sqlalchemy.exc import IntegrityError
|
||||
|
||||
from app.config import QueueNames
|
||||
from app.dao.fact_billing_dao import fetch_usage_year_for_organisation
|
||||
from app.dao.organisation_dao import (
|
||||
dao_create_organisation,
|
||||
dao_get_organisations,
|
||||
@@ -127,9 +130,9 @@ def get_organisation_services(organisation_id):
|
||||
|
||||
@organisation_blueprint.route('/<uuid:organisation_id>/services-with-usage', methods=['GET'])
|
||||
def get_organisation_services_usage(organisation_id):
|
||||
services = dao_get_organisation_services(organisation_id)
|
||||
sorted_services = sorted(services, key=lambda s: (-s.active, s.name))
|
||||
return jsonify([s.serialize_for_org_dashboard() for s in sorted_services])
|
||||
services = fetch_usage_year_for_organisation(organisation_id, datetime.utcnow().year)
|
||||
|
||||
return jsonify(services=services)
|
||||
|
||||
|
||||
@organisation_blueprint.route('/<uuid:organisation_id>/users/<uuid:user_id>', methods=['POST'])
|
||||
|
||||
Reference in New Issue
Block a user