Commit Graph

5332 Commits

Author SHA1 Message Date
Rebecca Law
ab695d24d5 Added new endpoints to get service data retention for a service. 2018-07-13 15:18:27 +01:00
Rebecca Law
e2a1dfeb31 New dao and endpoints to create and update service data retention. 2018-07-11 17:02:49 +01:00
Rebecca Law
e4cc90e585 Fix merge conflict 2018-07-11 10:09:33 +01:00
Rebecca Law
df0df55402 Added unique constraint for service_id + notification_type
Change updated_at to have onupdate rather than default.
2018-07-11 10:09:33 +01:00
Rebecca Law
b71f6777e9 Create a table SERVICE_DATA_RETENTION to store the number of days the notification is to be kept for. 2018-07-11 10:09:33 +01:00
Rebecca Law
91c7858904 Merge branch 'master' of github.com:alphagov/notifications-api 2018-07-11 10:08:37 +01:00
Rebecca Law
12aa9436e0 Merge pull request #1942 from alphagov/fix-old-jobs
Clean up old, incomplete jobs
2018-07-10 15:54:03 +01:00
Rebecca Law
526831504d Merge branch 'master' of github.com:alphagov/notifications-api 2018-07-10 15:46:49 +01:00
Rebecca Law
b3ab96c60e Merge pull request #1941 from alphagov/revert-1936-fix-old-incomplete-jobs
Revert "Clean up old, incomplete jobs"
2018-07-10 15:44:49 +01:00
Rebecca Law
1c54ef090d Clean up old, incomplete jobs 2018-07-10 15:39:51 +01:00
Rebecca Law
57d684bd0f Revert "Clean up old, incomplete jobs" 2018-07-10 15:37:39 +01:00
Rebecca Law
c1699cd0a5 Merge pull request #1936 from alphagov/fix-old-incomplete-jobs
Clean up old, incomplete jobs
2018-07-10 15:35:23 +01:00
Katie Smith
07d274c2e6 Merge pull request #1935 from alphagov/new-letter-billing
Migration for new letter pricing
2018-07-10 11:42:09 +01:00
Katie Smith
c57f33a02d Use real letter_rates in tests
Added the letter_rate table to the list of tables which does not get
deleted after each test run and changed the tests to use the real letter
rates.

Also removed the letter rate DAO since this was only being used in
tests, so was no longer needed.
2018-07-10 11:31:18 +01:00
Katie Smith
8f211e00f5 Migration for new letter pricing
We now support letters of up to 5 sheets long, so we need to store the
rates for 4 and 5 sheet letters (both crown and non-crown) in the
`letter_rates` table.
2018-07-10 09:34:42 +01:00
Chris Hill-Scott
d5469a9772 Clean up old, incomplete jobs
We have a few old jobs which don’t have a `processing_started` date.
This means that they always sort to the top of the jobs list in admin,
no matter how old they are. We think this is due to an old bug where
jobs would not be updated if a deploy was in progress.

This commit backfills the `processing_started` data for these jobs,
which will be roughly accurate. Complete accuracy is not the goal;
having these jobs not sort to the top of the list is.

This will affect 5 jobs across 3 services on production:
```sql
select service_id, job_status, created_at, updated_at, processing_started, processing_finished, notification_count, notifications_sent, notifications_delivered, notifications_failed from jobs where processing_started is null and job_status = 'in progress';
```

```
service_id              | job_status  |         created_at         |         updated_at         | processing_started | processing_finished | notification_count | notifications_sent | notifications_delivered | notifications_failed
--------------------------------------+-------------+----------------------------+----------------------------+--------------------+---------------------+--------------------+--------------------+-------------------------+----------------------
d47e5a1b-a04b-4398-8935-c8a266ce1d44 | in progress | 2017-09-29 13:49:41.512356 | 2017-10-01 02:01:05.281162 |                    |                     |              10615 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-09-29 09:25:39.802623 | 2017-09-29 16:01:02.154291 |                    |                     |              10240 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-09-29 09:31:52.455919 | 2017-09-29 16:01:01.990054 |                    |                     |               9930 |                  0 |                       0 |                    0
128b91b6-2996-4107-bb65-51b7c24a728d | in progress | 2017-08-22 08:15:39.125999 | 2017-08-22 16:01:07.758805 |                    |                     |               6967 |                  0 |                       0 |                    0
95316ff0-e555-462d-a6e7-95d26fbfd091 | in progress | 2016-05-27 14:44:18.114564 | 2016-06-13 00:18:14.542795 |                    |                     |               2742 |               2238 |                     525 |                 1713
(5 rows)
```
2018-07-09 11:33:15 +01:00
Leo Hemsted
6705f9d209 Merge pull request #1933 from alphagov/delete-service-stuff
Delete service apis (callback + inbound)
2018-07-06 15:19:01 +01:00
Chris Hill-Scott
f4cb3ab9b5 Merge pull request #1932 from alphagov/pyup-update-pytest-3.6.2-to-3.6.3
Update pytest to 3.6.3
2018-07-05 16:00:38 +01:00
Chris Hill-Scott
22673e0755 Merge pull request #1934 from alphagov/hackney-logo
Add letter organisation for Hackney Council
2018-07-05 16:00:00 +01:00
Chris Hill-Scott
8ceca4a068 Add letter organisation for Hackney Council 2018-07-05 15:50:38 +01:00
Leo Hemsted
32415b3b14 add delete functions for inbound and callback api objects
Both service api tasks work fine if the object is unexpectedly deleted
halfway through - they both check to see if the api details are still
in the DB before trying to send the request.
2018-07-05 11:09:17 +01:00
pyup-bot
325e111fd8 Update pytest from 3.6.2 to 3.6.3 2018-07-04 23:45:06 +01:00
Katie Smith
7015e240e0 Merge pull request #1929 from alphagov/paginate-complaints
Paginate complaints
2018-07-04 15:34:46 +01:00
Rebecca Law
9680946fbf Merge pull request #1931 from alphagov/fix-nightly-status
Fix task name for notification status updates
2018-07-04 15:23:06 +01:00
Leo Hemsted
4502dffa13 include date being processed in the migrate nightly stats command 2018-07-04 14:54:27 +01:00
Rebecca Law
317ab149f4 The periodic task to populate ft_notification_status was calling the wrong task, this fixes that. 2018-07-04 14:12:47 +01:00
Leo Hemsted
732106119a Merge pull request #1930 from alphagov/monthly-statuses-page
Monthly statuses page from ft_notification_status
2018-07-04 13:36:56 +01:00
Leo Hemsted
be52adc68f add tests for monthly notification stats 2018-07-03 14:58:32 +01:00
Leo Hemsted
00e9fee471 make sure we combine stats that are already there
eg we have yesterdays data and want to top it up with todays deltas

'use a defaultdict to make this painless'
2018-07-03 14:58:32 +01:00
Leo Hemsted
1589bb58bb make sure test keys are filtered out of stats 2018-07-03 14:58:32 +01:00
Leo Hemsted
22496d9161 move stats endpoints to new file
(no new tests for new endpoint included in this commit)
2018-07-03 14:58:32 +01:00
Leo Hemsted
089056ef72 add tests for new statistics and fact notification status functions 2018-07-03 14:58:32 +01:00
Leo Hemsted
75fdb0290f remove old monthly stats function 2018-07-03 14:57:19 +01:00
Leo Hemsted
2463cd8fb5 move monthly notification stats from notification history to ft tables
it now uses the ft_notification_status table - nice and quick. if you
ask for the current tax year it'll top up the data with numbers from
the notification table.

the data is in exactly the same shape as the old endpoint - no changes
to the admin app are necessary
2018-07-03 14:56:31 +01:00
Katie Smith
b0540098ad Fix randomly failing test
The results of the DAO function do not always get returned in the same
order, so this test was occasionally failing.
2018-07-03 11:11:49 +01:00
Katie Smith
3398e4cf93 Paginate the function to get all complaints
The DAO function to get all complaints has been paginated and the
endpoint which uses it has been updated to take a page number as a query
parameter.
2018-07-03 11:11:49 +01:00
Rebecca Law
e3b3a407c9 Merge pull request #1918 from alphagov/wrap-get_json-in-try-except
Wrap exception to return a sensible message to the client
2018-07-03 11:03:01 +01:00
Rebecca Law
6da552a00b Added a message before the error description, to explain that it's the input arguments that have caused a problem. 2018-07-03 09:41:02 +01:00
Katie Smith
d2f8a206a8 Merge pull request #1928 from alphagov/platform-stats-fix
Fix aggregate stats DAO function to use start_date
2018-07-03 09:33:05 +01:00
Katie Smith
4228b77ebb Fix aggregate stats dao function to use start_date
Now using start_date to determine which table to query.
2018-07-03 09:26:02 +01:00
Rebecca Law
13155e24dc We are getting 500 errors when a POST notification has characters that can not be decoded or the json is malformed.
The exception is wrapped and a sensible error message is returned to the client.
2018-07-03 09:04:33 +01:00
Rebecca Law
e1a7d99c72 Merge pull request #1927 from alphagov/improve-last-usage-query
Improve the performance of the query to get the last template usage.
2018-07-03 08:55:47 +01:00
Rebecca Law
db5663e429 Improve the performance of the query to get the last template usage.
By adding the service id, the query performance has improved greatly. It went from 6200ms to 0.04ms.
This should stop the 500s when a template is deleted.
2018-07-02 17:17:38 +01:00
Katie Smith
3bc9c06c3c Merge pull request #1919 from alphagov/new-platform-stats-endpoint
New endpoint for the updated platform admin stats page
2018-07-02 15:37:24 +01:00
Leo Hemsted
3b5eefdd3d Merge pull request #1923 from alphagov/pyup-update-sqlalchemy-1.2.8-to-1.2.9
Update sqlalchemy to 1.2.9
2018-07-02 14:30:42 +01:00
Leo Hemsted
956822ee94 Merge pull request #1925 from alphagov/bump-utils-for-email-validation
Updated notifications-util to the latest version
2018-07-02 14:30:31 +01:00
Leo Hemsted
cb8b17e7d3 Merge pull request #1926 from alphagov/letter-timezone-bug
fix letters being put in the wrong bucket when near midnight cut-off
2018-07-02 14:28:59 +01:00
Leo Hemsted
cb7f5a7166 fix letters being put in the wrong bucket when near midnight cut-off
another day, another timezone bug
2018-07-02 14:16:40 +01:00
Rebecca Law
08dcc920a2 Updated notifications-util to the latest version.
There has been an update to the email validation code.
Added an extra test for email validation.
2018-07-02 13:48:40 +01:00
Rebecca Law
69c01ce8a0 Merge pull request #1924 from alphagov/replay-letters-in-error
Added a method to reply letters that are in the error folder on S3.
2018-07-02 11:05:13 +01:00