Commit Graph

7236 Commits

Author SHA1 Message Date
Katie Smith
92c979fcdb Restore provider resting points
We temporarily updated the provider resting points in
https://github.com/alphagov/notifications-api/pull/2804.
This puts the provider resting points back to their original value now
that both providers seem to be functioning well.
2020-04-20 10:45:19 +01:00
Pea M. Tyczynska
d15db5702c Merge pull request #2807 from alphagov/make-sure-letter-personalisation-is-string
Make sure letter personalisation is string - pull utils patch
2020-04-17 18:29:17 +01:00
Pea Tyczynska
f27e544911 Make sure letter personalisation is string - pull utils patch 2020-04-17 13:42:57 +01:00
Chris Hill-Scott
47b5ae9dc1 Merge pull request #2801 from alphagov/use-new-utils-template-properties
Use new properties of utils Templates
2020-04-17 13:41:45 +01:00
Pea Tyczynska
fef03920f0 Add test for a callback with a code 2020-04-17 10:58:26 +01:00
Pea Tyczynska
470d00c26e Make comment clearer following review 2020-04-17 10:58:25 +01:00
Pea Tyczynska
a4507dbb3f Use firetext response code to see if temporary or permanent failure if available 2020-04-17 10:58:25 +01:00
Pea Tyczynska
91fe68eed4 WIP read firetext response codes 2020-04-17 10:58:25 +01:00
Chris Hill-Scott
5ddb5a75da Use new properties of utils Templates
We’ve added some new properties to the templates in utils that we can
use instead of doing weird things like
`WithSubjectTemplate.__str__(another_instance)`
2020-04-15 16:40:42 +01:00
David McDonald
9b1b9ea75b Merge pull request #2798 from alphagov/delete-notifications-older-than-retention
Delete notifications older than retention
2020-04-15 12:14:07 +01:00
David McDonald
e366fc5f70 Merge pull request #2804 from alphagov/provider-swap
Move provider resting balance as temporary measure
2020-04-14 18:20:15 +01:00
David McDonald
8a27b3b9f2 Move provider resting balance as temporary measure
We are seeing issues with one of our providers. Move all traffic to the
other. We have done this with the provider load balancer, however this
will be reverted back 10 percent every hour to these resting points,
which we want to stop happening until we are confident our provider has
fixed their issues.

In the long run, we should add functionality to pause our load balancer
behaviour.
2020-04-14 18:07:25 +01:00
Leo Hemsted
ee25dc79e4 Merge pull request #2802 from alphagov/delete-around-midnight
fix timezone related cancel letter job bug
2020-04-14 15:40:23 +01:00
Leo Hemsted
7fe075393d fix timezone related cancel letter job bug 2020-04-14 14:32:36 +01:00
Chris Hill-Scott
f90c475126 Merge pull request #2793 from alphagov/refactor-postcode-validation
Allow any three lines in the address for templated letters
2020-04-14 12:51:22 +01:00
Chris Hill-Scott
36e61272c5 Save the first non-empty line as recipient
Since we now allow the address to be populated from any three lines, we
can’t guarantee that the recipient will be in the `addressline1` field.
2020-04-09 18:19:53 +01:00
Chris Hill-Scott
7032bac178 Start allowing any three lines in addresses
This is part of moving away from `postcode` and towards `address line 7`

We think it will be easier for people to map their existing data to our
API if we let them fill in any 3 lines, instead of requiring at least
1, 2, and postcode specifically.
2020-04-09 18:19:53 +01:00
Chris Hill-Scott
264fbed04e Refactor postcode validation to use utils
We don’t need to reformat the postcode here once template preview takes
care of it when rendering the PDF.

It’s better (and less code) to store what people give us, so we give
them back the same thing.
2020-04-09 18:19:53 +01:00
Katie Smith
e2985161bb Merge pull request #2799 from alphagov/revert-2747-update-postage-constraint
Revert "Update postage db constraints for international letters"
2020-04-08 11:33:08 +01:00
Katie Smith
4fd74af3bd Revert "Update postage db constraints for international letters" 2020-04-08 10:53:51 +01:00
Katie Smith
f0c5463440 Merge pull request #2747 from alphagov/update-postage-constraint
Update postage db constraints for international letters
2020-04-08 08:23:43 +01:00
Chris Hill-Scott
c94c2f087c Merge pull request #2797 from alphagov/fix-v2-preview-response
Ensure correct object renders V2 template preview
2020-04-07 17:19:07 +01:00
Chris Hill-Scott
054cd16d02 Ensure correct object renders V2 template preview
The `body` field of the ‘preview a template’ endpoint should contain the
content of the template with the placeholders replaced.

It should not be rendered into a plain text email, which does stuff like
normalising newlines (so `\r\n` becomes `\n`). However the object that
the `create_post_template_preview_response` function receives is an
instance of `PlainTextEmailTemplate`. So we can’t just call `str()` on
it. Instead we need to call the `__str__` method of
`WithSubjectTemplate` which gives us the result we want.

We were already doing this the right way in the V1 endpoint[1] but
forgot to do it here too.

1. 0108749daa/app/template/rest.py (L181-L184)
2020-04-07 17:09:59 +01:00
David McDonald
f512fc63a1 Run delete-notifications-older-than-retention at 3am
Moving it from 4:15am to 3:00. This will mean we do more deleting before
the 'work day' starts and improve our DB performance.

I've looked at the last 14 day of logs for the
`create-nightly-notification-status` subtasks and the
`create-nightly-billing` subtasks. The latest they appear to finish is
2.30AM. There were some outliers but I believe these were people running
the tasks in the middle of the day as a manual process.

Obviously, this still means there is a risk that those tasks conflict
with `delete-notifications-older-than-retention`, even more so now that
we move this to 3am.
2020-04-07 17:04:31 +01:00
David McDonald
085e3a8435 Make deleting of notifications to be sequential
Based on this https://github.com/alphagov/notifications-api/pull/2788
where some concerns were raised. This should be a quicker fix to get our
the deletions to run sequentially for all the notification types. Note,
email is first as most important as makes up the larger numbers (we
wouldn't want it to start with SMS, fail half way for a reason that only
affects SMS and for that to affect the email deletion).

We hope that by running sequentially we will reduce conflicts writing to
the same index and this will speed up the total time it takes to finish
deleting all notification types older than their retention time. There
is a risk that whilst quicker per job, as they now run sequentially
rather than potentially overlapping, they will take longer overall. We
will need to monitor to see.
2020-04-07 17:03:17 +01:00
Chris Hill-Scott
0108749daa Merge pull request #2795 from alphagov/extract-placeholders-from-all-parts-of-letter-template
Look in all parts of a letter template to find placeholders
2020-04-07 15:20:43 +01:00
Chris Hill-Scott
025ac3ea89 Use same template to validate and send notification
To be absolutely sure that we can send a message we should also validate
it using the same template class that we use to render it.
2020-04-07 10:41:16 +01:00
Chris Hill-Scott
8c8c8b6328 Look in all parts of a letter template to find placeholders
Text messages have placeholders in their body.

Emails have them in their subject line too.

Letters have them in their body, subject line and contact block.

We were only looking in the the body and subject when processing a job,
therefore the thing assembling the letter was not looking in all the
CSV columns it needed to, because it hadn’t been told about any
placeholders in the contact block.

Fixing this means always making sure we use the correct `Template`
instance for the type of template we’re dealing with. Which we were
already doing in a different part of the codebase. So it makes sense to
reuse that.

Turns out we fixed the same bug for email subjects over 3 years ago:
3ed97151ee
2020-04-07 10:41:16 +01:00
Katie Smith
e2effb6ee1 Update JSON schema postage validation for new values 2020-04-07 08:01:11 +01:00
Katie Smith
186670e10e Update postage db constraints for international letters
The `notifications`, `notification_history`, `templates` and `templates_history`
tables all had a check constraint on the postage column which specified
that the postage had to be `first` or `second` if the notification or
template was a letter. We now have two more options for postage -
`europe` and `rest-of-world`.

It's not possible to alter a check constraint, so the constraints have
to be dropped then recreated. We are not recreating the constraint on
the `notification_history` table since values here are always copied
from the `notifications` table.

The constraints get added as `NOT VALID` at first - this stage will lock
the tables, so updating the `notification` table and `templates` and
`templates_history` are done in separate migrations so that we don't lock
all tables at the same time. In a third migration we then run
`VALIDATE CONSTRAINT` for all tables - this will lock a row at a time,
not the whole table.
2020-04-07 08:01:11 +01:00
Leo Hemsted
ae5b0e143c Merge pull request #2794 from alphagov/provider-ratios
Update provider splits
2020-04-06 15:27:38 +01:00
Leo Hemsted
9673619519 Update provider splits
also fix tests so they're independent of future config changes
2020-04-06 15:16:00 +01:00
Katie Smith
e386d2ac38 Merge pull request #2792 from alphagov/delete-old-letter-task
Delete old 'process-virus-scan-passed-task'
2020-04-03 09:35:35 +01:00
Katie Smith
6e1800a436 Merge pull request #2787 from alphagov/delete-unused-tasks
Delete two tasks that weren't being used
2020-04-03 09:35:22 +01:00
Katie Smith
6ac89c9a2f Delete old 'process-virus-scan-passed-task'
This has been replaced by a new task, `sanitise-letter`, to this deletes
all the code in the old task and ensures that when antivirus is not
enabled locally we are calling the new task.
2020-04-02 14:52:15 +01:00
Katie Smith
62b11bc61e Delete delete_dvla_response_files_older_than_seven_days task
This was not being used.
2020-04-02 14:49:47 +01:00
Katie Smith
bfd40a843c Delete send-scheduled-notifications task
This was added a few years ago, but never used.
2020-04-02 14:45:18 +01:00
David McDonald
e07dea27e1 Merge pull request #2791 from alphagov/link-to-runbook
Link to runbook
2020-04-02 10:28:49 +01:00
David McDonald
98d8388805 Add runbook link to ticket 2020-04-02 09:42:46 +01:00
David McDonald
b28fffc330 Refactor raise_alert_if_letter_notifications_still_sending
Move finding of letter logic into a separate method so it can be unit
tested rather than having to test it by checking the contents of a
zendesk ticket api call.

This will enable us to change the zendesk api ticket call message
without needing to edit lots of tests.
2020-04-02 09:36:56 +01:00
Pea M. Tyczynska
bf7a662b26 Merge pull request #2790 from alphagov/increase-startup-timeout
Increase startup timeout to 15 minutes
2020-04-01 15:27:17 +01:00
Pea Tyczynska
8a1a59a920 Increase startup timeout to 15 minutes - as it takes longer with 35 minimum instances 2020-04-01 15:11:06 +01:00
Pea M. Tyczynska
642eff9563 Merge pull request #2786 from alphagov/add-freezetime
Add missing freezetime to a test
2020-04-01 12:02:35 +01:00
Pea Tyczynska
f8286fdd21 Add missing freezetime to a test 2020-04-01 11:53:13 +01:00
Pea M. Tyczynska
cff7f7b72d Merge pull request #2751 from alphagov/validate-and-format-postcode-api-flow
Validate and format postcode for the API letter sending flow.
2020-04-01 11:09:25 +01:00
Rebecca Law
ac8fc49539 Merge pull request #2770 from alphagov/increase-qry-limit
Increase default query limit to 50,000 from 10,000
2020-03-31 17:15:12 +01:00
Rebecca Law
a7a158fe69 Merge pull request #2784 from alphagov/add-team-key-to-query
Add team key to query
2020-03-31 17:13:42 +01:00
Rebecca Law
ee45a2096c Merge pull request #2785 from alphagov/index-optimisation-1
Optimise indexes
2020-03-31 16:00:03 +01:00
Katie Smith
113ab4805f Merge pull request #2775 from alphagov/task-retries
Add retries to process_sanitised_letter task
2020-03-31 15:39:31 +01:00
Katie Smith
6d7bf5eef8 Merge pull request #2783 from alphagov/bump-utils
Bump utils to 36.9.3 to bring in new version of Bleach
2020-03-31 15:39:14 +01:00