mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-10 10:03:21 -04:00
Start to build a page to performance platform page.
This commit is contained in:
committed by
Chris Hill-Scott
parent
3d590a71e4
commit
042527e74c
@@ -100,6 +100,9 @@ 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 (
|
||||||
|
performance_platform_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,
|
||||||
)
|
)
|
||||||
@@ -185,6 +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,
|
||||||
platform_stats_api_client,
|
platform_stats_api_client,
|
||||||
provider_client,
|
provider_client,
|
||||||
service_api_client,
|
service_api_client,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from app.main.views import ( # noqa isort:skip
|
|||||||
new_password,
|
new_password,
|
||||||
notifications,
|
notifications,
|
||||||
organisations,
|
organisations,
|
||||||
|
performance_platform,
|
||||||
platform_admin,
|
platform_admin,
|
||||||
providers,
|
providers,
|
||||||
register,
|
register,
|
||||||
|
|||||||
21
app/main/views/performance_platform.py
Normal file
21
app/main/views/performance_platform.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
from flask import jsonify, request
|
||||||
|
|
||||||
|
from app import performance_platform_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})
|
||||||
|
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()
|
||||||
|
|
||||||
|
stats = performance_platform_api_client.get_performance_platform_stats(api_args)
|
||||||
|
return jsonify(stats)
|
||||||
10
app/notify_client/performance_platform_api_client.py
Normal file
10
app/notify_client/performance_platform_api_client.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
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()
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
from app.notify_client.performance_platform_api_client import (
|
||||||
|
PerformancePlatformAPIClient,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_aggregate_platform_stats(mocker):
|
||||||
|
client = PerformancePlatformAPIClient()
|
||||||
|
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)
|
||||||
|
mock.assert_called_once_with('/performance-platform', params=params_dict)
|
||||||
Reference in New Issue
Block a user