mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-08 07:58:25 -04:00
Rename to performance-dashboard
This commit is contained in:
committed by
Chris Hill-Scott
parent
042527e74c
commit
3ca2840652
@@ -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.notification_api_client import notification_api_client
|
||||||
from app.notify_client.org_invite_api_client import org_invite_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.organisations_api_client import organisations_client
|
||||||
from app.notify_client.performance_platform_api_client import (
|
from app.notify_client.performance_dashboard_api_client import (
|
||||||
performance_platform_api_client,
|
performance_dashboard_api_client,
|
||||||
)
|
)
|
||||||
from app.notify_client.platform_stats_api_client import (
|
from app.notify_client.platform_stats_api_client import (
|
||||||
platform_stats_api_client,
|
platform_stats_api_client,
|
||||||
@@ -188,7 +188,7 @@ def create_app(application):
|
|||||||
notification_api_client,
|
notification_api_client,
|
||||||
org_invite_api_client,
|
org_invite_api_client,
|
||||||
organisations_client,
|
organisations_client,
|
||||||
performance_platform_api_client,
|
performance_dashboard_api_client,
|
||||||
platform_stats_api_client,
|
platform_stats_api_client,
|
||||||
provider_client,
|
provider_client,
|
||||||
service_api_client,
|
service_api_client,
|
||||||
|
|||||||
@@ -1,21 +1,17 @@
|
|||||||
from datetime import datetime, timedelta
|
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 import main
|
||||||
from app.main.forms import DateFilterForm
|
|
||||||
|
|
||||||
|
|
||||||
@main.route("/performance-platform")
|
@main.route("/performance-dashboard")
|
||||||
def performance_platform():
|
def performance_dashboard():
|
||||||
form = DateFilterForm(request.args, meta={'csrf': False})
|
|
||||||
api_args = {}
|
api_args = {}
|
||||||
|
|
||||||
form.validate()
|
api_args['start_date'] = (datetime.utcnow() - timedelta(days=90)).date()
|
||||||
# default date range is 3 months
|
api_args['end_date'] = datetime.utcnow().date()
|
||||||
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()
|
|
||||||
|
|
||||||
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)
|
return jsonify(stats)
|
||||||
|
|||||||
10
app/notify_client/performance_dashboard_api_client.py
Normal file
10
app/notify_client/performance_dashboard_api_client.py
Normal file
@@ -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()
|
||||||
@@ -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()
|
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
from app.notify_client.performance_platform_api_client import (
|
from app.notify_client.performance_dashboard_api_client import (
|
||||||
PerformancePlatformAPIClient,
|
PerformanceDashboardAPIClient,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_aggregate_platform_stats(mocker):
|
def test_get_aggregate_platform_stats(mocker):
|
||||||
client = PerformancePlatformAPIClient()
|
client = PerformanceDashboardAPIClient()
|
||||||
mock = mocker.patch.object(client, 'get')
|
mock = mocker.patch.object(client, 'get')
|
||||||
params_dict = {'start_date': '2021-03-01', 'end_date': '2021-03-31'}
|
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)
|
mock.assert_called_once_with('/performance-platform', params=params_dict)
|
||||||
|
|||||||
Reference in New Issue
Block a user