Commit Graph

2723 Commits

Author SHA1 Message Date
Rebecca Law
00b17b5ad7 When we sent the service the status callback for a notification, we have all the information we need.
Which means we can remove the need to request the data from the database.
In order for the PR to be backwards compatible I have added an optional parameter "encrypted_status_update".
If this is not None then the new code is called.

The next PR will send the encrypted data to this task.

A final PR will remove the code that uses the database to get the notification and service callback api.
2018-03-08 16:17:41 +00:00
Leo Hemsted
651c3062b9 retry service callbacks if the db queries fail
we don't expect them to fail, but they might if we accidentally
exhaust our connection pool. Just in case, lets retry.
2018-03-08 14:08:56 +00:00
Chris Waszczuk
1a63847988 Merge pull request #1746 from alphagov/add-is-org-unique-rest-endpoint
Add endpoint to check for unique organisation names
2018-03-08 12:11:06 +00:00
Chris Hill-Scott
c029927fde Merge pull request #1733 from alphagov/remove-dvla
Remove anything to do with DVLA format letters
2018-03-08 10:58:34 +00:00
Richard Chapman
94dea42f6f Merge pull request #1747 from alphagov/add_precompiled_letters
Fixed bug only where only data being passed to TemplatePreview when JSON is required
2018-03-08 09:56:03 +00:00
Chris Hill-Scott
ae0113a5de Merge pull request #1748 from alphagov/quis-patch-1
Add warning to Performance Platform command
2018-03-07 17:13:46 +00:00
Richard Chapman
d60e802f35 Removed the superfluous variable and pass through as it pulls it
automatically out of sys.exc_info.
2018-03-07 09:51:58 +00:00
Katie Smith
7f2e9f507e Delete functions which call the job statistics tasks
The JobStatistics table is going to be deleted. There are currently
3 tasks which use the JobStatistics model via the Statistics DAO, so we
need to make sure that these tasks aren't being used before they are
deleted in a separate PR.

This commit deletes:
* The `create_initial_notification_statistic_tasks` function which gets
used to call the `record_initial_job_statistics` task.
* The `create_outcome_notification_statistic_tasks` function which gets
used to call the `record_outcome_job_statistics` task.
* And the scheduling of the `timeout-job-statistics` scheduled task.
2018-03-07 09:23:29 +00:00
Katie Smith
0c1d5c12a3 Merge pull request #1699 from alphagov/persist-sorted-in-letter-response-file
Create and populate DailySortedLetter table
2018-03-07 09:06:33 +00:00
Chris Hill-Scott
5db3eef8f2 Add warning to Performance Platform command 2018-03-06 15:42:38 +00:00
Richard Chapman
77a3397ce5 Added option flag to the _get_png_preview method to determine if the
post method content is data or json format.
2018-03-06 15:35:00 +00:00
chrisw
a487293bf0 Add check org name is unique endpoint 2018-03-06 15:34:39 +00:00
Richard Chapman
ed9936bba0 Fixed bug where the content header was not being passed onto the post
request. Changed data => json.

Added extra logging to display the error with more detail
2018-03-06 14:42:53 +00:00
Richard Chapman
d0df85a602 Fixed bug where the content header was not being passed onto the post
request. Changed data => json.

Added extra logging to display the error with more detail
2018-03-06 14:24:30 +00:00
Chris Hill-Scott
d7823fdbd6 Merge pull request #1739 from alphagov/backfill-performance-totals
Add command to backfill Performance Platform totals
2018-03-06 09:38:26 +00:00
Katie Smith
136d89e2f1 Persist daily sorted letter counts from response file
In the update_letter_notifications_statuses task we now check whether
each row in the response file that we receive from the DVLA has the
value of 'Sorted' or 'Unsorted' in the postcode validation field. We
then calculate the number of Sorted and Unsorted rows for each day and
save each day as a row in the daily_sorted_letter table.

The data in daily_sorted_letter table should be in local time, so we
convert the datetime before saving.
2018-03-06 09:09:02 +00:00
Katie Smith
1b5aaed10a Create DAO for daily sorted letter model 2018-03-06 09:09:02 +00:00
Katie Smith
b0de3ba4d9 Create DailySortedLetter table
The response files we receive from the DVLA when we send letters
contain a row for each letter and a field with a value of 'Unsorted' or
'Sorted'. This table will be used to store the total number of
'Unsorted' and 'Sorted' letter notifications per day.
2018-03-06 09:09:02 +00:00
Richard Chapman
271e157d1a Merge pull request #1737 from alphagov/add_precompiled_letters
Updated API to handle pre-compiled pdfs
2018-03-06 08:39:49 +00:00
Chris Hill-Scott
ca167206d5 Add command to backfill Performance Platform totals
We don’t have any way of playing back the totals we send to performance
platform.

This commit copies the command used to backfill the processing time and
adapts it to backfill the totals instead. Under the hood it uses the
same code that we use in the scheduled tasks to update performance
platform on a daily basis. I had to modify this code to take a `day`
argument because it was hardcoded to only work for ‘yesterday’.
2018-03-05 17:02:33 +00:00
Richard Chapman
e91a0efc43 Refactored code to make it more maintainable and changed an error type
* Rather than an abort 404 returned a 500 and InvalidRequest so that the
error is more easily handled on the admin console. If the file is
missing but expected to be there is actually an internal error for admin
* Refactored the code to remove duplicate code in calls to template
preview by creating a new private method which is called with specific
parameters
2018-03-05 14:54:18 +00:00
Richard Chapman
a4feaba309 Added tests to tests for precompiled flow and refactored a little
* Added is_precompiled_letter method to letter/utils.py
* Added tests for letter/utils.py
* Added tests for the rest endpoint
* Moved the Precompiled name to a central location
* Added hidden field to the test method to create a template
2018-03-05 14:11:37 +00:00
Chris Hill-Scott
7e1aa03371 Send count of sent letters to performance platform
Now we’ve been sending real letters for quite a while it would be nice
to show how many.
2018-03-02 16:54:48 +00:00
Richard Chapman
a9a67ce542 Updated API to handle pre-compiled pdfs
* added a method to letter/utils.py to get the PDF document from the S3
bucket
* added the logic to return the pdf or to produce a png of the pdf
2018-03-02 14:54:28 +00:00
Chris Hill-Scott
7ef6af2d14 Remove anything to do with DVLA format letters 2018-03-02 14:13:12 +00:00
Rebecca Law
8aea452df9 Because research mode and test keys do not create notification history, a try except block has been added. 2018-03-02 11:37:15 +00:00
Rebecca Law
c474b2312b Process responses for letters even after the notification has been deleted.
This will continue to update the notification history for letter notifications.
We currently have an issue where the responses to letters from the provider is taking a long time.
This is due to the manual nature of their process.
Updating the status of the letter will still work if the notification has been purged.

Also turned back on the purge letter notification scheduled task.
2018-03-02 11:29:22 +00:00
Rebecca Law
d6c929d127 Another unused method to delete 2018-03-02 11:05:06 +00:00
Rebecca Law
bffc4863db Remove all methods no longer used now that we only send pdf files to DVLA. 2018-03-02 11:05:05 +00:00
Rebecca Law
304f4d5c67 Remove unused methods 2018-03-02 11:05:05 +00:00
Richard Chapman
42c1040604 Updated API to get it working with Admin.
* Added missing items from template which are required
* Returned the file as a JSON string with the file as a base64 encoded
string
* Updated tests to match teh desired format
2018-03-01 15:01:46 +00:00
Richard Chapman
4c8bc9f430 Added endpoint to get the letter preview from the template preview app
Is will allow the admin application to call into the api instead of
making the call itself. This will allow the api to make decision for
precompiled pdf without having to update the admin app.

- Added new endpoint
- Added tests for the endpoint
2018-03-01 15:01:46 +00:00
Rebecca Law
99a3dc8959 Merge pull request #1726 from alphagov/add-notification-id-to-log
Update log message
2018-03-01 12:19:48 +00:00
Rebecca Law
be7989bbc9 Suspend the delete-letter-notifications scheduled job.
We have an issue with the provider. If we need to resend these letters, we need the notification.
2018-03-01 11:47:00 +00:00
Rebecca Law
891a80addf Added notification id to the log message for upload pdf to make it easier to search for the letter notification in the logs. 2018-03-01 10:37:07 +00:00
Chris Hill-Scott
9524e34ce1 Revert "Send one-off messages as fast as possible" 2018-03-01 10:17:59 +00:00
Chris Hill-Scott
f0d91bf1c5 Merge pull request #1722 from alphagov/priority-one-off-2
Send one-off messages as fast as possible
2018-03-01 09:38:09 +00:00
Katie Smith
bc619efc4e Count the number of pages in pre-compiled letters
We were already counting the billable units in PDFs that we generate.
We are now also counting the number of billable units in pre-compiled letters
and saving the result.
2018-02-28 16:14:25 +00:00
Chris Hill-Scott
bc2e55a6b8 Send one-off messages as fast as possible
The vast majority of messages that are being sent one-off are
time-sensitive. A typical example is a caseworker on the phone who sends
a message at the end of the call. They normally wait until the message
has been delivered, so all the time they’re waiting is time when they
can’t be helping someone else.

What we don’t want to happen is for the messages they’re sending to get
stuck behind a big lump of GOV.UK Subscription emails or passport
reminder texts. I think the best way to do this is shift them onto the
priority queue.

We’re currently seeing queue sizes of up to 5,000 on the ‘normal’
queues; I don’t think there’s any risk of this change making the
priority queue more heavily-laden than this. Especially since the
traffic patterns of users sending one-off messages won’t be spiky.
2018-02-28 15:00:12 +00:00
Rebecca Law
12046ee85a There endpoint to check the token of an invitation for services and organisations have been merged.
This PR deletes the old endpoints.
2018-02-27 13:46:23 +00:00
kentsanggds
25d84af63e Merge pull request #1709 from alphagov/ken-fix-letter-serialization
Fix serialization on precompiled letter
2018-02-27 10:13:15 +00:00
Rebecca Law
7faf375375 Merge pull request #1695 from alphagov/org-user-endpoints
Organisation user endpoints
2018-02-26 16:27:01 +00:00
Ken Tsang
c14663d84a Fix serialization on precompiled letter
Postcodes are required for created letters, but not for precompiled, this fix allows postcodes to be None in the model.
As postcodes are still required for created letter they should be caught by validation schemas in the POST handler
2018-02-26 13:53:06 +00:00
Alexey Bezhan
984a5050db Don't return hidden templates in API service template responses
Brings back filtering hidden templates from the API responses.
2018-02-26 13:28:08 +00:00
Alexey Bezhan
9b3a9a55c4 Revert "Don't return hidden templates in API service template responses"
Filtering out hidden templates requires all existing templates to
have `hidden` flag set, which can only be done by a migration after
the code that sets the flag to `False` by default for new templates
has been released.

This removes the filtering logic until the migration has been released.
2018-02-26 11:44:25 +00:00
Alexey Bezhan
19dbe7da8d Don't return hidden templates in API service template responses
Removes hidden templates from the service templates list and returns
404 when searching for a hidden template or template versions by ID.
2018-02-23 17:52:25 +00:00
Alexey Bezhan
d803b48d23 Return 400 response for invalid per-compiled letter content 2018-02-23 17:52:25 +00:00
Alexey Bezhan
bef91bcd99 Check for precompiled letter permission in the post notification 2018-02-23 17:52:25 +00:00
Alexey Bezhan
8971a5adce Upload pre-compiled letter PDF to S3
Pre-compiled letter endpoint uploads PDF contents to S3 directly
instead of creating a letter task to generate PDF using template
preview.

This moves some of the utility functions used by existing letter
celery tasks to app.letters.utils, so that they can be reused by
the API endpoint.
2018-02-23 17:52:25 +00:00
Alexey Bezhan
5327298371 Add a view function for pre-compiled PDF letters
Adds a separate view function that is registered under the same
route as existing letter POST notification.
2018-02-23 17:52:24 +00:00