Commit Graph

7553 Commits

Author SHA1 Message Date
Chris Hill-Scott
57473ef65d Rename template_content to content
`template_content` is a template that hasn't had its placeholders filled
in whereas content is where it would have (which is what has happened
above)
2020-10-08 11:39:17 +01:00
Chris Hill-Scott
80352bafe1 Update test to check personalisation
While the API still has a column and field for personalisation I think
it makes sense for it to consider the personalisation when serialising
the broadcast, so we should have a test for this.

This way the API still works as a coherent whole, and the admin app just
happens to be a client of the API which doesn’t implement the
personalisation feature.

If we want to remove personalisation from the API at another time we
should do it wholesale.
2020-10-07 10:52:31 +01:00
Chris Hill-Scott
7da0d46767 Serialise content in broadcast message response
This will let us show the content of the broadcast message in places we
can’t at the moment.
2020-10-02 16:39:24 +01:00
David McDonald
cfe32cf459 Merge pull request #2975 from alphagov/rename-redis-template-keys
Step 2 of renaming cache keys for templates
2020-10-02 14:26:03 +01:00
Chris Hill-Scott
f2314333b5 Merge pull request #2982 from alphagov/improve-efficiency-of-process-missing-rows
Improve efficiency of process missing rows task
2020-10-02 11:23:35 +01:00
Chris Hill-Scott
298761070c Merge pull request #2987 from alphagov/bump-utils-42.2.1
Bump utils to 42.2.1
2020-09-29 14:33:01 +01:00
Chris Hill-Scott
29ff625a4b Bump utils to 42.2.1
Changes: https://github.com/alphagov/notifications-utils/compare/42.2.0...42.2.1
2020-09-29 12:34:44 +01:00
Chris Hill-Scott
19963b9b58 Merge pull request #2984 from alphagov/add-stats-endpoint-for-scheduled-jobs
Add an endpoint for stats about scheduled jobs
2020-09-29 10:24:09 +01:00
Leo Hemsted
59839d21b8 Merge pull request #2974 from alphagov/make-letter-folder-name-code-readable
Make letter folder name code readable
2020-09-28 13:58:08 +01:00
Chris Hill-Scott
4cee47da68 Add more tests for scheduled job stats
Ensures we don’t count jobs that are in a different status, or belong to
another service.
2020-09-28 13:15:39 +01:00
Rebecca Law
8974ec2550 Merge pull request #2985 from alphagov/reduce-logs
Reduce logs
2020-09-28 12:05:17 +01:00
Rebecca Law
e4e61b1e4b Merge pull request #2978 from alphagov/add-reference-to-msg
Add reference to log message
2020-09-28 12:04:59 +01:00
Rebecca Law
d1f641633d Reduce logs
The log message is not necessary, let's get rid.
2020-09-28 11:53:54 +01:00
Chris Hill-Scott
2fcde009ac Add an endpoint for stats about scheduled jobs
At the moment we display the count of scheduled jobs on the dashboard
by sending all the scheduled jobs to the admin app and letting it work
out the stats.

This is inefficient and, because the get jobs response has a page size
of 50, becomes incorrect if a service schedules more than 50 jobs.

This commit adds a separate endpoint which gives the admin app the stats
it needs directly and correctly.
2020-09-28 09:57:32 +01:00
Chris Hill-Scott
1c4775c5db Merge pull request #2983 from alphagov/run-scheduled_jobs
Make run-scheduled jobs to run every minute
2020-09-27 11:48:03 +01:00
Rebecca Law
e86c6b23c4 Make run-scheduled jobs to run every minute 2020-09-27 11:30:12 +01:00
Chris Hill-Scott
1d50bfaafc Remove unused column from query 2020-09-26 12:11:15 +01:00
Chris Hill-Scott
9ad33045dd Improve efficiency of process missing rows task
For every missing row this was:
- downloading the CSV file from S3
- looping through every row in it until it found the one matching the
  index of the missing row

`RecipientCSV` implements `__getitem__`[1] (which maybe it didn’t
before) so we can create it once, then index the relevant row directly.

***

1. 5ae0572d41/notifications_utils/recipients.py (L78-L79)
2020-09-26 12:06:48 +01:00
Chris Hill-Scott
f651176343 Merge pull request #2981 from alphagov/allow-20-mins-before-checking-missing-rows
Allow 20 minutes before checking for missing rows
2020-09-26 11:59:29 +01:00
Chris Hill-Scott
aace1bdd8a Allow 20 minutes before checking for missing rows
Since we’ve doubled the number of rows in a job, jobs can take twice as
long to insert all the notifications. We don’t check for missing rows
until we’re pretty confident that the original tasks have finished
processing. This means we need to double the time we wait to still be
as sure.
2020-09-26 11:38:38 +01:00
Chris Hill-Scott
2af62bdd1f Merge pull request #2980 from alphagov/bump-utils-42.2.0
Bump utils to 42.2.0
2020-09-25 18:24:13 +01:00
Chris Hill-Scott
379a227a1d Bump utils to 42.2.0
Increases CSV row limit from 50,000 to 100,000

Changes: https://github.com/alphagov/notifications-utils/compare/42.0.0...42.2.0
2020-09-25 18:16:14 +01:00
David McDonald
391a006376 Merge pull request #2979 from alphagov/sms-callback-app
add notify-api-sms-callbacks app
2020-09-25 10:40:52 +01:00
Leo Hemsted
9d5b629dad add notify-api-sms-callbacks app
we might need to deal with a potential large volume of SMS delivery
receipts. These receipts are POSTed to oru public api to two URLs. The
actual endpoint just parses the response body and puts a task on an SQS
queue - no database connections are required or anything like that.

Split up this traffic from other traffic, so that any increase in volume
of callbacks won't affect the scaling/load/etc of the main api apps.
We've hard coded instance counts to 10 on prod for now until we get an
idea of load.
2020-09-24 18:00:25 +01:00
Leo Hemsted
078a40f4da Merge pull request #2977 from alphagov/add-broadcast-org
add broadcast org
2020-09-24 14:21:08 +01:00
Rebecca Law
d7e53cdf50 Adding reference to message for "precompiled letters have been pending-virus-check for over 90 minutes"
This saves having to go to the db to get it.
2020-09-24 14:16:16 +01:00
Leo Hemsted
aac6b16b3c add broadcast org
keep the ID the same as the existing prod broadcast org to keep things
simple.

Move all services with a broadcast permission across to this new
service. Note that we'll need to clear the service and organisation
cache after deploying this
2020-09-23 17:05:17 +01:00
David McDonald
5b0cc8819a Use new redis key for templates
Equivalent of https://github.com/alphagov/notifications-admin/pull/3639
but for the API.

This is the only place in the API we appear to be getting setting
templates or broadcast messages.
2020-09-21 17:40:54 +01:00
Leo Hemsted
1e928a926a rename sending_date to created_at
we don't name letters based on the day we send them on, rather, the day
we create them on. If we process a letter for a second time for whatever
reason, even if it's a couple of days later, it'll still go in a folder
based on the created_at timestamp. There's still a slight confusion,
however - if the timestamp is after 5:30pm, the folder will be for the
day after. However, still the day after creation, so I think created_at
still makes the most sense.

Remove the term `sending_date` to try and make this relationship more
apparent.
2020-09-21 14:40:22 +01:00
Leo Hemsted
4f1e5ee5a3 remove ignore_folder from get_folder_name
it doesn't make sense to get the folder name if you know you aren't
going to use it.
2020-09-21 14:33:38 +01:00
Leo Hemsted
bb33927b3d rename letter get_folder_name args
`_now`? why would we ever use a different _now? instead say created_at,
because that's what it'll always be set to, even if we're replaying old
letters. We always set the folder name to when the letter was
created_at, or we might not know where to look to find it.

`dont_use_sending_date` doesn't really tell us what might happen if we
don't use it - the answer is we return an empty string. we ignore the
folder entirely. so lets call it that.

Also, remove use of freeze_gun in the tests, to prove that we don't use
the current time in any calculations. Also add an assert to a mock in
the get_pdf_for_templated_letter test, because we were mocking but not
asserting before, so the tests didn't fail when the function signature
changed.
2020-09-21 14:32:57 +01:00
David McDonald
120b760cae Merge pull request #2972 from alphagov/broadcast-invite-template
Broadcast invite template
2020-09-16 14:34:31 +01:00
David McDonald
f9911c7965 Send broadcast invite email for broadcast service invites
This means the copy is more accurate and mentions sending emergency
alerts rather than previous copy about sending emails texts and letters.
2020-09-15 16:47:41 +01:00
David McDonald
23ac7bcf56 Use sample broadcast service instead of sample service for tests
We only want to use a service that has permissions for broadcasts to
make our tests more realistic
2020-09-15 16:47:41 +01:00
David McDonald
6620590aad Add template for broadcast service invite 2020-09-15 16:47:41 +01:00
Katie Smith
15b782d595 Merge pull request #2971 from alphagov/fix-international-filenames
Fix the filenames for international precompiled letters
2020-09-15 16:45:10 +01:00
Katie Smith
aee7887c14 Fix the filenames for international precompiled letters
We were determing the filename for precompiled letters before we had
checked if the letters were international. This meant that a letter
could have a filename indicating it was 2nd class, but once we had
sanitised the letter and checked the address we were setting the
notification to international.

This stopped these letters from being picked up to be sent to the DVLA,
since the filename and postage of the letter did not match.

We now regenerate the filename after the letter has been sanitised (and when
we know the postage) and use the updated filename when moving the letter
into the live PDF letters bucket.
2020-09-15 16:17:33 +01:00
David McDonald
507e50d822 Merge pull request #2970 from alphagov/fix-govuk-link
Bring in latest version of utils to fix link breaking bug
2020-09-14 15:40:14 +01:00
David McDonald
5b2dee5ddb Bump utils to 42.0.0
Requires unit test updating as we now expect broadcast event areas to
be a dict containing a list of areas and simple polygons.
2020-09-14 15:21:55 +01:00
David McDonald
d352c99142 Remove unused send_broadcast_message task
We only call send_broadcast_event now
2020-09-14 15:16:59 +01:00
David McDonald
5aee6269e0 Fix format of simple_polygons
It is not of the form
[[lat, long][lat, long]] as this would only hold a single polygon. It
instead needs to handle multiple polygons so instead is of the form
[[[lat, long][lat, long]]].
2020-09-14 14:55:01 +01:00
David McDonald
288e3ae811 Bring in latest version of utils to fix link breaking bug
Fixes https://github.com/alphagov/notifications-utils/pull/784

Note, also is a breaking change of the utils, see
https://github.com/alphagov/notifications-utils/pull/769
but I don't believe it requires any changes on the API because of this
2020-09-10 14:32:02 +01:00
Rebecca Law
8d4228dd55 Merge pull request #2963 from alphagov/catch-exception-for-event
Catch and log any exception thrown in the checkin event method.
2020-09-10 13:16:08 +01:00
Rebecca Law
da4efbbb82 Catch and log any exception thrown in the checkin event method.
We don't want an exception while recording metrics to affect a user action. A KeyError exception was thrown today, that meant that a user say a 500, the action being performed was to download a document from the document-download-frontend app. By catching the error we prevent the user from seeing a 500 when a recording the connection metric fails.

Also catch the exception in the checkout event.
2020-09-10 12:25:35 +01:00
Chris Hill-Scott
92af5b8d67 Merge pull request #2968 from alphagov/cancel-international-letters
Allow international letters to be cancelled
2020-09-09 14:10:23 +01:00
Chris Hill-Scott
0e1f6f31e4 Use constant for notification type
Co-authored-by: Katie Smith <klssmith@users.noreply.github.com>
2020-09-09 11:12:06 +01:00
Chris Hill-Scott
cfda289746 Allow international letters to be cancelled
Our code was assuming that any notifications with `international` set to
`True` were text messages. It was then trying to look up delivery
information for a notification which wasn’t sent to a phone number,
causing an exception.
2020-09-09 10:55:55 +01:00
Rebecca Law
ea36a3804e Merge pull request #2967 from alphagov/fix-update-organisations
Fix update organisations
2020-09-09 10:55:33 +01:00
Rebecca Law
795a035fac When the organisation updates the crown attribute it should update all the services associated with that organisation too. 2020-09-09 10:43:16 +01:00
Pea M. Tyczynska
a9168d38a7 Merge pull request #2965 from alphagov/send-polygons-to-api
Persist simple polygons in the db.
2020-09-08 12:08:53 +01:00