diff --git a/app/__init__.py b/app/__init__.py index 204b03af9..e1ce3ccd5 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -100,8 +100,8 @@ from app.notify_client.letter_jobs_client import letter_jobs_client from app.notify_client.notification_api_client import notification_api_client from app.notify_client.org_invite_api_client import org_invite_api_client from app.notify_client.organisations_api_client import organisations_client -from app.notify_client.performance_platform_api_client import ( - performance_platform_api_client, +from app.notify_client.performance_dashboard_api_client import ( + performance_dashboard_api_client, ) from app.notify_client.platform_stats_api_client import ( platform_stats_api_client, @@ -188,7 +188,7 @@ def create_app(application): notification_api_client, org_invite_api_client, organisations_client, - performance_platform_api_client, + performance_dashboard_api_client, platform_stats_api_client, provider_client, service_api_client, diff --git a/app/main/views/performance_platform.py b/app/main/views/performance_platform.py index b0857dc1b..9e777ae09 100644 --- a/app/main/views/performance_platform.py +++ b/app/main/views/performance_platform.py @@ -1,21 +1,17 @@ from datetime import datetime, timedelta -from flask import jsonify, request +from flask import jsonify -from app import performance_platform_api_client +from app import performance_dashboard_api_client from app.main import main -from app.main.forms import DateFilterForm -@main.route("/performance-platform") -def performance_platform(): - form = DateFilterForm(request.args, meta={'csrf': False}) +@main.route("/performance-dashboard") +def performance_dashboard(): api_args = {} - form.validate() - # default date range is 3 months - api_args['start_date'] = form.start_date.data or datetime.utcnow().date - timedelta(months=3) - api_args['end_date'] = form.end_date.data or datetime.utcnow().date() + api_args['start_date'] = (datetime.utcnow() - timedelta(days=90)).date() + api_args['end_date'] = datetime.utcnow().date() - stats = performance_platform_api_client.get_performance_platform_stats(api_args) + stats = performance_dashboard_api_client.get_performance_dashboard_stats(api_args) return jsonify(stats) diff --git a/app/notify_client/performance_dashboard_api_client.py b/app/notify_client/performance_dashboard_api_client.py new file mode 100644 index 000000000..20f7d895c --- /dev/null +++ b/app/notify_client/performance_dashboard_api_client.py @@ -0,0 +1,10 @@ +from app.notify_client import NotifyAdminAPIClient + + +class PerformanceDashboardAPIClient(NotifyAdminAPIClient): + + def get_performance_dashboard_stats(self, params_dict=None): + return self.get("/performance-dashboard", params=params_dict) + + +performance_dashboard_api_client = PerformanceDashboardAPIClient() diff --git a/app/notify_client/performance_platform_api_client.py b/app/notify_client/performance_platform_api_client.py deleted file mode 100644 index a82b77e64..000000000 --- a/app/notify_client/performance_platform_api_client.py +++ /dev/null @@ -1,10 +0,0 @@ -from app.notify_client import NotifyAdminAPIClient - - -class PerformancePlatformAPIClient(NotifyAdminAPIClient): - - def get_performance_platform_stats(self, params_dict=None): - return self.get("/performance-platform", params=params_dict) - - -performance_platform_api_client = PerformancePlatformAPIClient() diff --git a/tests/app/notify_client/test_performance_platform_api_client.py b/tests/app/notify_client/test_performance_platform_api_client.py index d2ffecdd4..25c1639b9 100644 --- a/tests/app/notify_client/test_performance_platform_api_client.py +++ b/tests/app/notify_client/test_performance_platform_api_client.py @@ -1,12 +1,12 @@ -from app.notify_client.performance_platform_api_client import ( - PerformancePlatformAPIClient, +from app.notify_client.performance_dashboard_api_client import ( + PerformanceDashboardAPIClient, ) def test_get_aggregate_platform_stats(mocker): - client = PerformancePlatformAPIClient() + client = PerformanceDashboardAPIClient() mock = mocker.patch.object(client, 'get') params_dict = {'start_date': '2021-03-01', 'end_date': '2021-03-31'} - client.get_performance_platform_stats(params_dict=params_dict) + client.get_performance_dashboard_stats(params_dict=params_dict) mock.assert_called_once_with('/performance-platform', params=params_dict)