Commit Graph

21 Commits

Author SHA1 Message Date
Kenneth Kehl
8c9721d8e2 notify-api-412 use black to enforce python coding style 2023-08-25 09:12:23 -07:00
Rebecca Law
b242467d77 Change the content for the delete template confirmation dialog.
As per https://www.pivotaltracker.com/story/show/170796514 we want to make the delete template confirmation dialog box more consistent and clear.
The API has been updated with a new endpoint that only returns the last-used date, this date is more accurate since it goes to the ft_notification_status table, if the notification table is empty.
2020-02-06 10:16:00 +00:00
Chris Hill-Scott
1d3a4e5043 Inherit don’t duplicate API client constructor
This removes some code which is duplicative and obscure (ie it’s not
very clear why we do `"a" * 73` even though there is a Very Good Reason
for doing so).
2019-01-29 12:11:27 +00:00
Chris Hill-Scott
9e798506c5 Initialise clients outside the app
This avoids the annoying problem where you can’t import a client unless
the app has already been initialised.
2018-10-30 14:59:24 +00:00
Alexey Bezhan
acfe8092fc Add route secret key header to the API requests
Currently requests to the API made from the admin app are going from
PaaS admin app to the nginx router ELB, which then routes them back
to the api app on PaaS.

This makes sense for external requests, but for requests made from
the admin app we could skip nginx and go directly to the api PaaS
host, which should reduce load on the nginx instances and
potentially reduce latency of the api requests.

API apps on PaaS are checking the X-Custom-Forwarder header (which
is set by nginx on proxy_pass requests) to only allow requests going
through the proxy.

This adds the custom header to the API client requests, so that they
can pass that header check without going through nginx.
2018-02-28 11:28:46 +00:00
Richard Chapman
155e432aa6 Disabled the template_history endpoint
- Updated tests and added a new mock_get_monthly_template_usage
- Deleted get_monthly_template_statistics_for_service
- Added new test to test the redirection of the old endpoint
2017-11-24 15:20:40 +00:00
Richard Chapman
d03df16db5 Added new template usage page which will replace template-activity
The current template-activity page is slow as it is using the end point
which uses notification_history  and hence is timing out. This adds a
new pages (so that they can be compared side by side) which will be
hidden until is is approved with the larger data set and tested.
2017-11-16 16:55:07 +00:00
Chris Hill-Scott
415e1a401a Don’t set combined API on Notify python client
Because we’re setting the API key and service ID after calling the
`__init__` method of the client it wasn’t doing the thing where it
splits the combined key into the two individual UUIDs. So we still need
to set them directly, individually on the client.
2017-07-26 12:08:10 +01:00
Chris Hill-Scott
5ddbe80ea9 Fix calls to API client which now takes fewer args
The Notify API client changed in version 4 to take two arguments, not
three (service ID was removed in favour of the combined API key).

This gets a bit gnarly because the API key has to be at least a certain
length so it can be substringed internally.
2017-07-26 11:10:37 +01:00
Chris Hill-Scott
4a226a7a29 Show template usage broken down by month
This follows on from:
- https://github.com/alphagov/notifications-admin/pull/1094
- https://github.com/alphagov/notifications-admin/pull/1109

It depends on:
- [ ] https://github.com/alphagov/notifications-api/pull/829

A year is too long. Month-by-month is a better timeframe for making
decisions or seeing patterns in your usage.
2017-03-16 14:04:37 +00:00
Martyn Inglis
08dc8fb13d Use the local APIClient rather than the one from the python-api-client
- ensures that all API calls set the request ID when talking to the API.
2016-11-30 17:01:44 +00:00
Chris Hill-Scott
92aacc1a54 Remove extraneous arguments to super
> dont need self.__class__, self in super - that's a python 2.x crutch.
> super() is equivalent
2016-09-12 14:59:53 +01:00
Chris Hill-Scott
5fda35c89d Make it clear that client do not use __init__
The clients never get passed useful values to their `__init__` methods.
Rather the real values are passed through later using the `init_app`
method.

So it should be an error if the client is relying on the values that
get passed to it’s init method. Easiest way to ensure this is by making
the `__init__` method not expect any arguments and passing fake values
to the `Super` call.
2016-09-12 12:18:19 +01:00
Chris Hill-Scott
fa5e5475e9 Update Python client
Just so that nobody else has to do it.

Implements:
- [x] https://github.com/alphagov/notifications-python-client/pull/29

Which is a breaking change requiring the renaming of method arguments.
2016-09-08 15:55:07 +01:00
Martyn Inglis
54e4311d1b Merged in the defensive code by mistake 2016-08-22 16:56:43 +01:00
Martyn Inglis
9fbd410474 Merge branch 'master' into use_new_template_stats_endpoint
Conflicts:
	app/notify_client/template_statistics_api_client.py
2016-08-22 16:47:42 +01:00
Martyn Inglis
f59e05fb1a Handle the API migration
If it;s the new format API hide the results

- Temp fix until new Admin code ships. Should be live for 5 mins.
2016-08-22 12:35:34 +01:00
Martyn Inglis
55c4443a05 Admin app uses the new API response formats. 2016-08-18 15:30:57 +01:00
Leo Hemsted
c4305d1610 only get template statistics for specific template 2016-06-07 14:28:02 +01:00
Chris Hill-Scott
312a903e65 Limit templates usage on dashboard to last 7 days
Previous the table of templates on the dashboard was for all time.
This commit uses the `limit_days` parameter of the API endpoint to only
show template usage from the last 7 days, aligning with the big numbers
shown above.
2016-04-20 15:02:29 +01:00
Adam Shimali
159fe60c1a Template statistics now surfaced on dashboard.
Job list removed.

Template statistics retrieved at same time as
notification stats.
2016-04-05 11:47:24 +01:00