mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-15 01:32:20 -05:00
notify-api-412 use black to enforce python style standards
This commit is contained in:
@@ -15,12 +15,14 @@ from app.performance_dashboard.performance_dashboard_schema import (
|
||||
)
|
||||
from app.schema_validation import validate
|
||||
|
||||
performance_dashboard_blueprint = Blueprint('performance_dashboard', __name__, url_prefix='/performance-dashboard')
|
||||
performance_dashboard_blueprint = Blueprint(
|
||||
"performance_dashboard", __name__, url_prefix="/performance-dashboard"
|
||||
)
|
||||
|
||||
register_errors(performance_dashboard_blueprint)
|
||||
|
||||
|
||||
@performance_dashboard_blueprint.route('')
|
||||
@performance_dashboard_blueprint.route("")
|
||||
def get_performance_dashboard():
|
||||
# All statistics are as of last night this matches the existing performance platform
|
||||
# and avoids the need to query notifications.
|
||||
@@ -31,21 +33,33 @@ def get_performance_dashboard():
|
||||
# If start and end date are not set, we are expecting today's stats.
|
||||
today = str(datetime.utcnow().date())
|
||||
|
||||
start_date = datetime.strptime(request.args.get('start_date', today), '%Y-%m-%d').date()
|
||||
end_date = datetime.strptime(request.args.get('end_date', today), '%Y-%m-%d').date()
|
||||
total_for_all_time = get_total_notifications_for_date_range(start_date=None, end_date=None)
|
||||
start_date = datetime.strptime(
|
||||
request.args.get("start_date", today), "%Y-%m-%d"
|
||||
).date()
|
||||
end_date = datetime.strptime(request.args.get("end_date", today), "%Y-%m-%d").date()
|
||||
total_for_all_time = get_total_notifications_for_date_range(
|
||||
start_date=None, end_date=None
|
||||
)
|
||||
total_notifications, emails, sms = transform_results_into_totals(total_for_all_time)
|
||||
totals_for_date_range = get_total_notifications_for_date_range(start_date=start_date, end_date=end_date)
|
||||
processing_time_results = get_processing_time_percentage_for_date_range(start_date=start_date, end_date=end_date)
|
||||
totals_for_date_range = get_total_notifications_for_date_range(
|
||||
start_date=start_date, end_date=end_date
|
||||
)
|
||||
processing_time_results = get_processing_time_percentage_for_date_range(
|
||||
start_date=start_date, end_date=end_date
|
||||
)
|
||||
services = get_live_services_with_organization()
|
||||
stats = {
|
||||
"total_notifications": total_notifications,
|
||||
"email_notifications": emails,
|
||||
"sms_notifications": sms,
|
||||
"notifications_by_type": transform_into_notification_by_type_json(totals_for_date_range),
|
||||
"processing_time": transform_processing_time_results_to_json(processing_time_results),
|
||||
"notifications_by_type": transform_into_notification_by_type_json(
|
||||
totals_for_date_range
|
||||
),
|
||||
"processing_time": transform_processing_time_results_to_json(
|
||||
processing_time_results
|
||||
),
|
||||
"live_service_count": len(services),
|
||||
"services_using_notify": transform_services_to_json(services)
|
||||
"services_using_notify": transform_services_to_json(services),
|
||||
}
|
||||
|
||||
return jsonify(stats)
|
||||
@@ -81,7 +95,12 @@ def transform_processing_time_results_to_json(processing_time_results):
|
||||
def transform_services_to_json(services_results):
|
||||
j = []
|
||||
for x in services_results:
|
||||
j.append({"service_id": x.service_id, "service_name": x.service_name,
|
||||
"organization_id": x.organization_id, "organization_name": x.organization_name}
|
||||
)
|
||||
j.append(
|
||||
{
|
||||
"service_id": x.service_id,
|
||||
"service_name": x.service_name,
|
||||
"organization_id": x.organization_id,
|
||||
"organization_name": x.organization_name,
|
||||
}
|
||||
)
|
||||
return j
|
||||
|
||||
Reference in New Issue
Block a user