Commit Graph

5574 Commits

Author SHA1 Message Date
Leo Hemsted
f73d9ef852 Merge pull request #2108 from alphagov/postage-constraint
Postage constraint
2018-09-27 13:45:49 +01:00
Leo Hemsted
69e08fa23b fix tests to create notifications properly
migrated away from calling fixtures as functions
2018-09-25 16:10:26 +01:00
Leo Hemsted
3739c573ea fix null check in constraint
There are two fun quirks of postgres/sql that we need to work around:
* any `x = y` where x or y is NULL returns NULL, rather than false.
* check constraints accept NULL or true values as good.

so, the check `postage in ('first', 'second')` returns `null` rather
than `false` when postage is null itself. This surprisingly passes the
check constraint. To get around this, we have to add an explicit not
null check as well.
2018-09-25 16:10:26 +01:00
Leo Hemsted
17612e5446 add postage constraint to notification history
A not valid constraint only checks against new rows, not existing rows.
We can call VALIDATE CONSTRAINT against this new constraint to check
the old rows (which we know are good, having run the command from
74961781). Adding a normal constraint acquires an ACCESS EXCLUSIVE
lock, but validate constraint only needs a SHARE UPDATE EXCLUSIVE lock.

see 9d4b8961 and 0a50993f for more information on marking constraints
as not valid.
2018-09-25 16:10:16 +01:00
Pea (Malgorzata Tyczynska)
d2962cdc10 Merge pull request #2096 from alphagov/new_letter_rates_from_10_2018
Introduce new letter rates, valid from 01.10.2018
2018-09-25 15:17:50 +01:00
Pea Tyczynska
ea3144c3fd Add downgrade steps to new rates migration, add end_date to old rates
and refactor migration statements for security good practice
2018-09-25 15:10:16 +01:00
Pea Tyczynska
165b65612e Change how rates are filtered by date to equal or greater 2018-09-25 15:10:16 +01:00
Pea Tyczynska
08fec8f928 Fix tests - update number fo letter rates in test 2018-09-25 15:10:16 +01:00
Pea Tyczynska
eed1d83187 Test that get_rate gets right rate based on post_class and date 2018-09-25 15:10:16 +01:00
Pea Tyczynska
86533c2366 Do not update the rate that doesn't change 2018-09-25 15:10:16 +01:00
Pea Tyczynska
0c0166922c Update migration number and get rid of explicit UTC zoning therein 2018-09-25 15:10:16 +01:00
Pea Tyczynska
85e57025b2 Define MMG inbound credentials for local in Development environment 2018-09-25 15:10:16 +01:00
Pea Tyczynska
39ebfb6826 Test filtering letter_rates by post_class 2018-09-25 15:10:16 +01:00
Pea Tyczynska
b3191dbc2a Filter letter rates by post_class in get_rate
Also adjust existing tests.
2018-09-25 15:10:15 +01:00
Pea Tyczynska
8b410e8876 Add new letter rates from 1st of October 2018 2018-09-25 15:10:15 +01:00
Rebecca Law
cb1a9a59c2 Merge pull request #2107 from alphagov/set-postage-on-file-name
Set postage on PDF filename from notification
2018-09-25 13:31:57 +01:00
Rebecca Law
a54645c5a3 Set the postage in the filename based on the postage set on the notification. 2018-09-25 11:04:58 +01:00
Leo Hemsted
ecbba69f53 Merge pull request #2103 from alphagov/populate-notification-postage
populate historic notification postage data
2018-09-24 11:13:07 +01:00
Sakis
a5ae9a21cd Merge pull request #2097 from alphagov/remove-http-healthcheck
Remove http healthcheck for api instances
2018-09-21 10:47:40 +01:00
Leo Hemsted
7496178156 populate historic notification postage data
sets all letters in notification history (and notifications) to
"second", so that there's no null letters for billing etc. Commits in
ten day chunks (up to ~30k letters)
2018-09-20 17:41:04 +01:00
Rebecca Law
1b7e0a8ec4 Merge pull request #2102 from alphagov/reduce-updates-to-notification
Reduce updates to notification
2018-09-20 16:01:43 +01:00
Rebecca Law
bb97a9038f Merge branch 'master' into reduce-updates-to-notification 2018-09-20 14:48:40 +01:00
Rebecca Law
b00308d122 Removed an update statement to notifications.
It's a small change, but we should remove any db operations that are not necessary.
2018-09-20 14:47:24 +01:00
Leo Hemsted
7c48dd2c4e Merge pull request #2100 from alphagov/notification-postage
Notification postage
2018-09-20 13:25:34 +01:00
Leo Hemsted
8e19a0742f remove default postage from noti history
also add test for notification_history properly setting
2018-09-20 12:26:58 +01:00
Leo Hemsted
4dc3f829e3 give letter notifications the postage from their service 2018-09-19 17:23:17 +01:00
Leo Hemsted
9021b43eb6 use pytest.param to contain marks like xfail or skip 2018-09-19 16:33:00 +01:00
Leo Hemsted
918e4b390f add postage to notification + noti_history
if it's a letter notification, postage must equal "first" or "second",
else it must equal null
2018-09-19 16:32:58 +01:00
Rebecca Law
645da3f33d Merge pull request #2098 from alphagov/postage-constraints
Add constraints to services.postage
2018-09-19 11:08:02 +01:00
Rebecca Law
01ef8dd379 Merge pull request #2099 from alphagov/add-valid-message
Added an info log message when the precompiled pdf is successful.
2018-09-19 11:05:12 +01:00
Rebecca Law
a30ed976f4 Added an info log message when the precompiled pdf is successful. This is because we can't tell when the letters are passing. 2018-09-18 17:46:19 +01:00
Rebecca Law
5f73dfdbe9 Added constraints to services.postage: not nullable and can only containt "first" or "second" 2018-09-18 17:41:25 +01:00
Rebecca Law
29a666302e Merge pull request #2092 from alphagov/letter-class-default-for-services
Add letter_class to Service
2018-09-18 17:03:55 +01:00
Rebecca Law
7200ccb452 Remove print 2018-09-18 16:44:07 +01:00
Rebecca Law
1c0892888f Change the name of letter_class to postage, this will match the domain language used in the documentation.
Updated the tests to answer review comments.
2018-09-18 15:22:08 +01:00
Athanasios Voutsadakis
2e12c68d2e Remove http healthcheck for api instances
This was introduced in #1811 as a way to avoid sending traffic to newly
created apps where gunicorn had not started yet, such as the case during
a scaling event. These days we depend mostly on scheduled scaling and we
rarely need to scale above the scheduled values.

Yesterday we had an event where (during a traffic spike) the healthcheck
failed causing the instance to be killed and sending a 5XX response code
to all the connections that this instance was handling at the time.

However, this instance was not unhealthy and was serving traffic. The
problem stems from a combination of using async workers, having to limit
the number of database connections and a thread holding onto a db
connection for the entire duration of the request.

Specifically, we end up having requests queued up in gunicorn waiting
for other requests to finish and release the db connection. Some pages
such as the dashboard generate queries that can take >5s.

If a healthcheck request is sent during a traffic spike and the instance in
question was "unfortunate" enough to get handled a few of these long
running queries, the healthcheck request will be queued up behind these
slow requests and will fail to receive a response within 1s [docs].

Ideally we should be able to configure the healthcheck timeout to a
value of our choosing, since we can end up in this situation again in
the future.

docs: https://docs.cloudfoundry.org/devguide/deploy-apps/healthchecks.html#types
2018-09-18 10:34:00 +01:00
Rebecca Law
efb618e956 Fix merge conflicts for the db migration file.
Update test_services_dao to stop using fixtures. This is a massive change. The only real change in the file is to check for the letter_class.
2018-09-17 15:45:29 +01:00
Rebecca Law
79815b4f8a In order to support sending letters by first class we need a way to know how the service wants us to send the letter.
To start with this will be an attribute on the service, at the time the notification is created it will look at Service.letter_class to decide what class to use for the letter.

This PR adds Service.letter class as a nullable column.
Updated the create_service and update_service method to default the value to second.

Subsequent PRs will add the check constraint to ensure we only get first or second in the letter_class column and make that column nullable.
This can't be done all at once because it will cause an error if someone inserts or updates a service during the deploy.
2018-09-17 11:27:43 +01:00
Chris Hill-Scott
39b01f145f Merge pull request #2090 from alphagov/glamorgan-rother-wealden
Add two new letter logos
2018-09-14 15:22:52 +01:00
Chris Hill-Scott
244e91021d Add two new letter logos 2018-09-14 13:58:50 +01:00
Alexey Bezhan
6ff9f81934 Merge pull request #2089 from alphagov/notification-history-onupdate
Change NotificationHistory.updated_at on update
2018-09-13 14:43:58 +01:00
Alexey Bezhan
c9ca720959 Change NotificationHistory.updated_at on update
Sets the updated_at to current time when the NotificationHistory
is modified (which happens occasionally for example to set status
to returned letter).
2018-09-13 14:09:09 +01:00
Rebecca Law
5b25b682d4 Merge pull request #2088 from alphagov/remove-trigger-letter-pdfs-for-day
Remove trigger-letter-pdfs-for-day
2018-09-13 13:30:04 +01:00
Rebecca Law
9b6d784876 Merge pull request #2087 from alphagov/remove-scheduled-notification-from-schema
Don't join to scheduled_notifications
2018-09-13 11:59:12 +01:00
Rebecca Law
f1b04193ca In this PR we remove trigger-letter-pdfs-for-day scheduled task and just call collate_letter_pdfs_for_day instead.
There was a datetime bug in the query which resulted in files not being sent to the postal provider.
The trigger-letter-pdfs-for-day task is no longer needed, so rather than fix the query just call collate_letter_pdfs_for_day directly.
Less code is always better.

Deployment considerations: I realized this is strictly not backwards compatible if the scheduled job is in progress and a task is on the queue that no longer exists. This is ok since we will deploy this well before 17:50.
2018-09-12 17:16:34 +01:00
Katie Smith
ae1ee85d12 Merge pull request #2049 from alphagov/pyup-update-sqlalchemy-1.2.10-to-1.2.11
Update sqlalchemy to 1.2.11
2018-09-12 11:24:28 +01:00
Katie Smith
3926453b1e Merge pull request #2079 from alphagov/pyup-update-pytest-cov-2.5.1-to-2.6.0
Update pytest-cov to 2.6.0
2018-09-12 11:24:19 +01:00
Katie Smith
36f11ab0d0 Merge pull request #2085 from alphagov/pyup-update-pytest-3.7.4-to-3.8.0
Update pytest to 3.8.0
2018-09-12 11:24:10 +01:00
Rebecca Law
f84087cd63 For the NotificationWithTemplateSchema exclude the scheduled_notifications so we do not query that table.
The scheduled_notifications is not used as of yet.
2018-09-11 16:52:56 +01:00
Rebecca Law
39b90f0b78 Merge pull request #2083 from alphagov/fix-date-conversion
Fix date conversion bug
2018-09-10 14:44:12 +01:00