Commit Graph
5604 Commits
Author SHA1 Message Date
Chris Hill-Scott 2708515f18 Bump utils to 30.5.2 2018-10-05 13:43:17 +01:00
Katie Smith 1bbcedf150 Merge pull request #2130 from alphagov/return-postage
Return postage from the monthly-usage endpoint
2018-10-04 14:03:46 +01:00
Katie Smith 236bbc5f28 Return postage from the monthly-usage endpoint
We were already returning the month, notification_type, billing_units
and rate from the /monthly-usage billing endpoint. This adds in the
postage too so that we can display postage details on the usage page of
admin.
2018-10-03 13:07:46 +01:00
Leo Hemsted 0843503b7a Merge pull request #2123 from alphagov/estimate-deliv-date
letter estimated delivery now takes postage into account
2018-10-03 11:44:52 +01:00
Leo Hemsted cffc697e7f letter estimated delivery now takes postage into account 2018-09-28 17:30:25 +01:00
Katie Smith ebc7f3e16b Merge pull request #2122 from alphagov/update-requirements
Update requirements
2018-09-28 16:45:37 +01:00
Katie Smith c2a6fc0439 Merge pull request #2112 from alphagov/add-postage-to-pk
Add postage to ft_billing primary key
2018-09-28 16:45:29 +01:00
Rebecca Law d5d84eb5ee Update requirements 2018-09-28 16:37:40 +01:00
Katie Smith 71d28035dd Update ft_billing with real postage data
* Changed update_fact_billing DAO function to update the table with the
real data for postage instead of hard-coding in 'second'.
* Added a test for the create nightly billing task to test that rows
with different postage are being inserted correctly.
2018-09-28 16:32:18 +01:00
Katie Smith f41e0f05ec Make postage column part of ft_billing primary key
Now that the postage column is populated and there are no null values,
it can be added to the composite primary key of ft_billing.
2018-09-28 16:19:49 +01:00
Katie Smith f034c26e19 Merge pull request #2121 from alphagov/fix-failing-test
Remove test
2018-09-28 15:14:03 +01:00
Katie Smith 0aedbff750 Remove test
Removed the occasionally failing test to check how ft_billing upserts
postage data. This test will be re-added once the postage column has been
added to the primary key.
2018-09-28 15:00:29 +01:00
Katie Smith 07f152e59e Merge pull request #2111 from alphagov/add-ft-billing-postage-column
Add ft_billing postage column
2018-09-28 14:48:46 +01:00
Katie Smith 6727f0e0f5 Update ft_billing DAO functions to use postage
* Updated the 'fetch_billing_data_for_day' DAO function to take postage into
account
* Updated the 'update_fact_billing' DAO function to insert postage for
new rows. When updating rows which are identical apart from the postage, the
original row will be kept. (This behaviour will change once postage is
added to the primary key - at this point, upserting will add a new row.)
* Also changed some fixtures / test set up functions to take postage
into account
2018-09-28 13:52:17 +01:00
Katie Smith 0b5da2b8ad Update command to migrate data to ft_billing
Updated the 'migrate-data-to-ft-billing' command to populate the new
postage column of ft_billing. This will be populated with the
postage of the notification for letters, or 'none' for email or sms. We
need to ensure there are no null values in postage so that the postage
column can become part of the primary key later.

Also updated the query to get the right rate letter rate now that we are
updating rates in the letter_rates table.
2018-09-28 13:52:17 +01:00
Katie Smith 0936060f5d Add postage column to ft_billing
Added a new varchar column, postage, to ft_billing. This is nullable and
not part of the composite primary key for now, but this will change
later.
2018-09-28 13:52:10 +01:00
Katie Smith 48db3a5e11 Delete unused functions
These deleted functions were only used for the old billing endpoints
which no longer exist.
2018-09-28 13:47:20 +01:00
Katie Smith 335aeb386f Update FactBilling model to reflect current database state
The FactBilling model and the ft_billing database table have diverged
slightly - this makes some minor changes to the model columns so that
the model matches the table (which appears to be the correct version).

The ft_billing table is currently like this:

       Column       |            Type             | Modifiers | Storage  | Stats target | Description
--------------------+-----------------------------+-----------+----------+--------------+-------------
 bst_date           | date                        | not null  | plain    |              |
 template_id        | uuid                        | not null  | plain    |              |
 service_id         | uuid                        | not null  | plain    |              |
 notification_type  | text                        | not null  | extended |              |
 provider           | text                        | not null  | extended |              |
 rate_multiplier    | integer                     | not null  | plain    |              |
 international      | boolean                     | not null  | plain    |              |
 rate               | numeric                     | not null  | main     |              |
 billable_units     | integer                     |           | plain    |              |
 notifications_sent | integer                     |           | plain    |              |
 updated_at         | timestamp without time zone |           | plain    |              |
 created_at         | timestamp without time zone | not null  | plain    |              |
Indexes:
    "ft_billing_pkey" PRIMARY KEY, btree (bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate)
    "ix_ft_billing_bst_date" btree (bst_date)
    "ix_ft_billing_service_id" btree (service_id)
    "ix_ft_billing_template_id" btree (template_id)
2018-09-28 13:47:20 +01:00
Katie Smith 82f07de200 Merge pull request #2116 from alphagov/update-first-class-rates-dates
Update first class letter rate start dates
2018-09-28 13:45:45 +01:00
Leo Hemsted 6aa4bfa426 Merge pull request #2118 from alphagov/fix-awscli
fix awscli botocore dependency
2018-09-28 11:37:29 +01:00
Leo Hemsted 78b4231915 fix awscli botocore dependency
awscli has a requirement of a new version of botocore

moto has a requirement of an old version of boto3, which requires an
old version of botocore

We had to pin boto to an older version, because of the moto issues.
this commit pins awscli to the version currently deployed on prod, so
that it plays nice with that older version of boto/botocore
2018-09-28 11:25:55 +01:00
Rebecca Law eeb705b68b Merge pull request #2114 from alphagov/dont-update-page-count
Do not update billable_units if page count does not match postal provider
2018-09-28 10:59:07 +01:00
Katie Smith 45e714e694 Update first class letter rate start dates
We want to bring the start dates for first class letter rates forward by
a month so that we don't see billing errors when sending first class letters now.
(The feature will still go live at the planned time - this is to let us test things
beforehand.)
2018-09-28 10:25:44 +01:00
Tom Byers b0549f9623 Merge pull request #2110 from alphagov/bump-utils
Bump utils to 30.4.0
2018-09-28 10:22:12 +01:00
Tom Byers 78cc503a91 Bump utils to 30.4.0
Brings in changes to allow letter timings to
include 1st class letters.

https://github.com/alphagov/notifications-utils/pull/533
2018-09-28 10:02:16 +01:00
Rebecca Law a4f357499d Sometimes the page counts from DVLA do not match our page counts. Our counts have always been right. This PR does not update notification with the DVLA page count but does still let us know the difference happened. 2018-09-27 16:13:15 +01:00
Leo Hemsted f0f54c0dff Merge pull request #2113 from alphagov/fix-noti-migration
separate notification postage constraint into three separate commits
2018-09-27 15:48:44 +01:00
Leo Hemsted 2b354eb5df separate notification postage constraint into three separate commits
we had an issue where the notification postage constraint command ran
into a deadlock, after trying to acquire two exclusive access locks on
large frequently modified/read tables.

To avoid this happening, we've had to split the upgrade script into
three - one script to apply the not-valid constraint to notifications
table, one for notification_history, and a third to validate the two
constraints.

Note: The first two scripts acquire exclusive access locks, but the
third only needs a row by row lock.

since this involves changing the exsiting alembic upgrades, if you've
upgraded your db you'll need to run the following three commands to
revert your database to a previous good state.

```
alter table notifications drop constraint chk_notifications_postage_null;
alter table notification_history drop constraint chk_notification_history_postage_null;
update alembic_version set version_num = '0229_new_letter_rates';
```
2018-09-27 15:20:28 +01:00
Tom Byers c126859efc Lock botocore library to <1.11.0
Using version 1.11.0 or above causes an error with
the moto library where it makes real HTTP requests
instead of mocking them:

https://github.com/spulec/moto/issues/1793

Until this is resolved, botocore needs to be
locked. This copies the approach the Digital
Marketplace team took to the same problem:

https://github.com/alphagov/digitalmarketplace-utils/pull/452
2018-09-27 14:38:29 +01:00
Leo Hemsted f73d9ef852 Merge pull request #2108 from alphagov/postage-constraint
Postage constraint
2018-09-27 13:45:49 +01:00
Tom Byers 8b86257a8b Bump utils to 30.3.1
Brings in stripping of the line separator
character from emails.

https://github.com/alphagov/notifications-utils/pull/531
2018-09-26 10:23:14 +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