Commit Graph

6994 Commits

Author SHA1 Message Date
Pea Tyczynska
8b60e69157 Finding only jobs and letters within data retention works and tested 2020-03-10 15:53:56 +00:00
Chris Hill-Scott
851435701f Merge pull request #2737 from alphagov/returned-letter-statistics
Add an endpoint to return returned letter stats
2020-03-05 16:11:09 +00:00
Chris Hill-Scott
6fd92c4931 Test for letters not returned recently
If you have some returned letters, but none in the last 7 days, we don’t
count how many you have in the last 7 days. But we should test to make
sure we’re not going to the database again.
2020-03-05 14:32:04 +00:00
David McDonald
2a4b1a58f8 Merge pull request #2739 from alphagov/statsd-prefix
Remove unused statsd_prefix variable
2020-03-05 13:43:47 +00:00
Chris Hill-Scott
02c824a980 Test for scenario when no returned letters exist 2020-03-05 11:10:32 +00:00
Chris Hill-Scott
70b2afa124 Rename method to be clear it’s recent-only 2020-03-05 11:10:32 +00:00
David McDonald
f56795655e Remove unused STATSD_PREFIX variable
We moved from sending statsd metrics to hosted graphite to sending to
one that is running on the paas. Therefore we no longer need to send
statsd metrics to a particular prefix at the statsd app as it is only
receiving statsd metrics from our apps (not other users like would have
been the case with HostedGraphite).

This should change no behaviour as the only place the environment
variable was being used was in the gunicorn config and it was an empty
string which is the default behaviour anyway as per:
https://docs.gunicorn.org/en/stable/settings.html#statsd-prefix
2020-03-05 10:41:26 +00:00
Chris Hill-Scott
8c47d07845 Optimise method to prevent redundant counting
If we know that the most recently returned letter was reported more than
7 days ago then we know, without having to go to the database again,
that the count of returned letters in the last 7 days is 0.
2020-03-05 10:00:30 +00:00
Chris Hill-Scott
9c03438a53 Add an endpoint to return returned letter stats
Currently the dashboard in the admin app pull the entire returned letter
summary for a service to calculate how many letters have been returned
in the last seven days.

Adding a separate endpoint for this purpose is better because:
- it’s a more efficient query
- it’s less data to send down the pipe
- it gives us a place to return the complete datetime, so the dashboard
  can be more precise about when the most recent report was
2020-03-03 17:16:54 +00:00
Chris Hill-Scott
b952b35714 Merge pull request #2726 from alphagov/launch-uploads
Give new services the upload letters permission
2020-03-03 14:38:32 +00:00
Chris Hill-Scott
223ec1360c Merge pull request #2735 from alphagov/dont-check-upload-letter-permission
Remove check on permission to upload letters
2020-03-03 12:04:01 +00:00
Chris Hill-Scott
aa69139fd1 Remove check on permission to upload letters
Soon enough every service will have this permission, and they won’t be
able to switch it off. So we should clean up our codebase and make it
so there’s no dependancy on a row existing in the permissions table.

This is the first step of that process for the API. Before we can remove
it, we have to stop checking from it. Next step will be to stop
inserting the permission, then finally remove it from the database.
2020-03-02 14:07:39 +00:00
Chris Hill-Scott
5c0e65a913 Merge pull request #2732 from alphagov/return-letter-upload-recipient
Return recipient for letter uploads
2020-02-28 15:29:39 +00:00
Chris Hill-Scott
f57b5445c3 Pass through template_type from DAO
The DAO sets template type to `None` for one-off letters, so the REST
method doesn’t need to do any special handling of it.
2020-02-28 09:58:13 +00:00
Pea M. Tyczynska
40ef0d0913 Merge pull request #2729 from alphagov/validate_send_file_by_email_contact_deets
All services can send files by email if they have set contact_link
2020-02-27 15:48:08 +00:00
Rebecca Law
ab2e44889e Merge pull request #2733 from alphagov/fix-organisation-usage-bug
Fix bug on organisation-usage page.
2020-02-27 15:06:12 +00:00
Rebecca Law
7b0a3c68cd Fix bug on organisation-usage page.
The dict is initialised for all live services, but if the organisation has trial mode services they cause a key error.
2020-02-27 13:52:02 +00:00
Chris Hill-Scott
c7895df82c Return recipient for letter uploads
If your caseworking system always spits out files with the same name it
will be hard to differentiate them when looking at the uploads page.

Seeing who the letter was sent to will help you differentiate them.

We can’t do this until the API returns the recipient.
2020-02-27 13:19:51 +00:00
Rebecca Law
ba24fe449b Merge pull request #2723 from alphagov/organisation-usage
Organisation usage
2020-02-27 10:34:23 +00:00
David McDonald
54491b372d Merge pull request #2731 from alphagov/pyup-scheduled-update-2020-02-26
Scheduled weekly dependency update for week 08
2020-02-27 10:15:28 +00:00
Rebecca Law
c91f37ff4c Change the updates to only look at today, and not yesterday. 2020-02-26 17:38:20 +00:00
Leo Hemsted
0e7049d49a freeze-requirements 2020-02-26 17:21:42 +00:00
Chris Hill-Scott
0ac9a035d5 Merge pull request #2728 from alphagov/return-template-type-on-jobs
Return template type for jobs
2020-02-26 16:24:24 +00:00
Chris Hill-Scott
94942f0928 Merge pull request #2730 from alphagov/24-2-96
Fix misnamed test
2020-02-26 16:24:17 +00:00
Chris Hill-Scott
a513017f3c Remove use of ‘hence‘
Probably more straightforward language to say ‘in the future’
2020-02-26 16:16:20 +00:00
Chris Hill-Scott
57e671267c Return template type in uploads response
We need template type for the uploads response, which will eventually
supercede the jobs response. At the moment the page uses both.
2020-02-26 16:14:57 +00:00
Rebecca Law
8d005f68dd Merge branch 'validate_send_file_by_email_contact_deets' of github.com:alphagov/notifications-api into validate_send_file_by_email_contact_deets 2020-02-26 16:10:46 +00:00
Rebecca Law
95d48d40a9 Update error message, now includes the url where the service can add contact details. 2020-02-26 16:04:15 +00:00
Pea M. Tyczynska
7ca35b44a7 Our new error message now has better grammar and form matching other errors more
Co-Authored-By: karlchillmaid <karl.chillmaid@digital.cabinet-office.gov.uk>
2020-02-26 13:38:48 +00:00
pyup-bot
5efbdbd2a2 Update marshmallow from 2.20.2 to 2.20.5 2020-02-26 13:00:13 +00:00
pyup-bot
d203072e55 Update marshmallow-sqlalchemy from 0.21.0 to 0.22.2 2020-02-26 13:00:11 +00:00
pyup-bot
0d3cf41a90 Update flask-marshmallow from 0.10.1 to 0.11.0 2020-02-26 13:00:10 +00:00
pyup-bot
a4cba39f09 Update cffi from 1.13.2 to 1.14.0 2020-02-26 13:00:08 +00:00
Rebecca Law
f7a564a17c Add more realistic test
Add statsd
Fix imports
2020-02-26 11:21:33 +00:00
Pea M. Tyczynska
6d21515adf Apply suggestions from code review
Better grammar for our new error message.

Co-Authored-By: karlchillmaid <karl.chillmaid@digital.cabinet-office.gov.uk>
2020-02-26 10:45:39 +00:00
Chris Hill-Scott
ddb6fd33b0 Fix misnamed test
At some point[1] we moved from being able to schedule a job for up to 24 hours to 96 hours. The test was not renamed accordingly.

1. https://github.com/alphagov/notifications-api/pull/711
2020-02-26 08:46:02 +00:00
Rebecca Law
67c64a8715 Format the response to a more managable list.
Add a sort order
2020-02-25 17:34:03 +00:00
Pea Tyczynska
9a12d0e80e Update error message after discussion with Karl 2020-02-25 17:10:22 +00:00
Chris Hill-Scott
8601b13595 Return template type for jobs
This is so we can display letter jobs in a different way on the admin
app (because it doesn’t make sense for them to have failed/delivered
counts like it does for email and text message jobs).

As elsewhere we use `fields.Method` to avoid serializing the whole
template object.
2020-02-25 16:13:12 +00:00
Pea Tyczynska
ed1bc8d806 All services can send files by email if they have set contact_link 2020-02-25 16:11:53 +00:00
Chris Hill-Scott
3739d6f407 Merge pull request #2725 from alphagov/bump-bleach
Bump utils to fix bleach security vulnerability
2020-02-25 14:42:52 +00:00
Chris Hill-Scott
b3c9680487 Give new services the upload letters permission
This will switch on this feature for new services.

After this we will:
- give existing services this permission with a database migration
- remove this permission from the codebase entirely so that everyone has
  this feature and can’t switch it off
2020-02-25 14:03:43 +00:00
Chris Hill-Scott
ee71dc7426 Bump utils to fix bleach security vulnerability 2020-02-25 11:02:41 +00:00
Rebecca Law
a2d18f8598 Update the organsition usage endpoint to use the new query.
This endpoint may need to change, but we'd like to see how this performs, so we'll test this with a real data set. Then come back to make sure the format is correct and check for missing tests for the endpoint,
2020-02-25 09:29:50 +00:00
Rebecca Law
b1b457eea0 Only return the usage data for live services.
The list of trail mode services is only for platform admins, therefore the usage isn't needed for that page.
2020-02-24 14:23:05 +00:00
Rebecca Law
18f272dc2b Add queries to handle returning usage for all services associated to a given organisation. 2020-02-24 11:28:42 +00:00
Rebecca Law
49533d7792 Fix typo in function name 2020-02-24 11:26:16 +00:00
David McDonald
42f02c8c24 Merge pull request #2717 from alphagov/collate-pdf
Look at all previous days when sending letters
2020-02-24 10:16:18 +00:00
Rebecca Law
1f143a0abf Merge pull request #2719 from alphagov/billing-dao-fix
Billing dao fix
2020-02-24 09:41:09 +00:00
David McDonald
2c41b21ddf Remove unnecessary code and unrelevant comment 2020-02-21 16:42:37 +00:00