mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-18 17:34:34 -05:00
* Refactored reports to use pregenerated docs instead * Fixed e2e test * Fixed anothr bug * Cleanup * Fixed timezone conversion * Updated ref files * Updated reference files, refreshed ui/ux for report generation. Buttons toggle on and off based on if report exists * Fixed linting errors, removed pytz * Fixed test failure * e2e test fix * Speeding up unit tests * Removed python time library that was causing performance issues with unit tests * Updated poetry lock * Unit test improvements * Made change that ken reccomended
41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
from datetime import datetime, timedelta
|
|
from itertools import groupby
|
|
from operator import itemgetter
|
|
from statistics import mean
|
|
|
|
from flask import render_template
|
|
|
|
from app import performance_dashboard_api_client, status_api_client
|
|
from app.main import main
|
|
from app.utils.csv import get_user_preferred_timezone_obj
|
|
|
|
|
|
@main.route("/performance")
|
|
def performance():
|
|
preferred_tz = get_user_preferred_timezone_obj()
|
|
stats = performance_dashboard_api_client.get_performance_dashboard_stats(
|
|
start_date=(datetime.now(preferred_tz) - timedelta(days=7)).date(),
|
|
end_date=datetime.now(preferred_tz).date(),
|
|
)
|
|
stats["organizations_using_notify"] = sorted(
|
|
[
|
|
{
|
|
"organization_name": organization_name or "No organization",
|
|
"count_of_live_services": len(list(group)),
|
|
}
|
|
for organization_name, group in groupby(
|
|
stats["services_using_notify"],
|
|
itemgetter("organization_name"),
|
|
)
|
|
],
|
|
key=itemgetter("organization_name"),
|
|
)
|
|
stats["average_percentage_under_10_seconds"] = mean(
|
|
[row["percentage_under_10_seconds"] for row in stats["processing_time"]] or [0]
|
|
)
|
|
stats["count_of_live_services_and_organizations"] = (
|
|
status_api_client.get_count_of_live_services_and_organizations()
|
|
)
|
|
|
|
return render_template("views/performance.html", **stats)
|