Commit Graph

542 Commits

Author SHA1 Message Date
Rebecca Law
d00614205e Adding test for fetch_biling_data_for_day. 2018-04-25 14:45:51 +01:00
Rebecca Law
16ef133aa5 Refactor reporting task so that methods can be used for the annual usage page.
Still a work in progress, tests are coming.
2018-04-25 14:45:51 +01:00
Rebecca Law
167f7a18e3 Fix the query that raises the alert for letters still in sending.
If Monday or Tuesday check for letters still sending after 4 days.
If Saturday or Sunday do nothing
If Wed, Thurs, Fri check for letters still sending after 2 days

Added test for Tuesday, corrected tests after the correction to query.
2018-04-25 10:10:25 +01:00
Katie Smith
417d382d1b Add extra day before raising letter still sending alert
We now want to wait an extra day before sending the alert that letters
are still sending.
2018-04-10 09:29:29 +01:00
Richard Chapman
82274123f4 Merge pull request #1817 from alphagov/rc_add_virus_scan_error_task
Logging refactor to make debugging Antivirus scans easier
2018-04-03 14:17:15 +01:00
Richard Chapman
f1abce22ae Logging refactor to make debugging easier. Before the filename needed to
be known. Added the notification id to the logging message so that
the notification can be traced through the logging system by knowing
the notification id, making it easier to debug. Also changed to raise an
exception so that alerts are generated. This way we should get an email
to say that there has been an error.
2018-04-03 12:31:52 +01:00
venusbb
52aeec2247 bug fix: use date only when comparing unique records rather than datetime 2018-03-29 11:42:31 +01:00
venusbb
cf766313e6 Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-report-tasks 2018-03-28 10:53:45 +01:00
venusbb
83aa1b9fa3 use datetime.combine rather than parser.parse 2018-03-28 10:52:37 +01:00
Rebecca Law
63e85e3511 Merge pull request #1806 from alphagov/update-logging
Update logging for provider tasks.
2018-03-27 14:04:12 +01:00
Richard Chapman
20179af6e6 Merge pull request #1802 from alphagov/rc_add_virus_scan_error_task
Added a new task to handle any error cases with the anti-virus
2018-03-27 14:03:24 +01:00
venusbb
2262db4f62 Database tweak and BST bug fix 2018-03-27 10:37:56 +01:00
Rebecca Law
c75458cee9 Revert change to exception log. 2018-03-26 16:44:29 +01:00
Rebecca Law
598539dcb3 Update logging for provider tasks.
Move the info message before the fetch.
Include the exception in the log message.
2018-03-26 15:24:21 +01:00
Richard Chapman
8b6d28d3b0 Added a new task to handle any error cases with the anti-virus
application. If the Anti-virus app fails due to s3 errors or ClamAV
so does not scan (even after retries) the file at all an error needs
to be raised and the notification set to technical-failure.

Files should be moved to a 'folder' a separate one for ERROR and FAILURE.

* Added new letter task to process the error
* Added a new method to letter utils.py to move a file into an error or
failure folder based on the input
* Added tests to test the task and the utils.py method
2018-03-26 14:18:44 +01:00
Rebecca Law
bdae669b05 Merge pull request #1800 from alphagov/replay-created-emails
Replay emails and sms that are still in created
2018-03-26 10:56:55 +01:00
Rebecca Law
9549ada200 Run task every 15 minutes.
Move variable to task from config.
2018-03-26 10:26:24 +01:00
Rebecca Law
28e78780d0 Added more logging for provider tasks. 2018-03-26 09:31:52 +01:00
Rebecca Law
f596d17bf2 If a sms or email has not been sent after 4 hours and 15 minutes then put it on the delivery queue. 2018-03-23 15:38:35 +00:00
kentsanggds
5d38989cd9 Merge pull request #1797 from alphagov/ken-test-key-antivirus
Add antivirus check on precompiled letters sent with test key
2018-03-23 15:04:08 +00:00
Ken Tsang
2f09c943f7 Change error log to exception log for pdfs failing virus scans 2018-03-23 14:24:23 +00:00
Ken Tsang
0ee5c33084 Add antivirus check on precompiled letters sent with test key
- precompiled PDFs sent by test key uploaded to scan bucket
- set status to VIRUS-SCAN-FAILED for pdfs failing virus scan rather than PERMANENT-FAILURE
- Make call to AV app for precompiled letters sent via a test key, and set notification status to PENDING-VIRUS-SCAN
2018-03-23 12:04:37 +00:00
venusbb
55a27fed13 fixed a bug on reporting_task 2018-03-23 11:40:27 +00:00
kentsanggds
5dc0248043 Merge pull request #1783 from alphagov/ken-process-antivirus
Send task to antivirus app and process antivirus callbacks
2018-03-21 16:39:55 +00:00
Ken Tsang
5481d743ac change failed virus scan log to error 2018-03-21 15:30:58 +00:00
venusbb
af975b89ec primary key for ft_billing should use notification_type 2018-03-21 15:02:08 +00:00
venusbb
378feda603 put import reporting_tasks in config 2018-03-21 10:39:00 +00:00
venusbb
cf019864e2 Preserve 'unknown' in ft_billing for sms if the provider is not known. 2018-03-21 09:50:34 +00:00
venusbb
ecef20523b Merge branch 'master' of https://github.com/alphagov/notifications-api into vb-report-tasks 2018-03-20 17:24:32 +00:00
venusbb
07aa44ea82 Add import report_tasks to schedule_tasks. 2018-03-20 16:42:24 +00:00
Ken Tsang
8391353113 Update tasks in line with AV app 2018-03-20 14:56:42 +00:00
Ken Tsang
b1ac580e0a Add celery tasks to handle virus scan passing and failing 2018-03-20 10:12:59 +00:00
Rebecca Law
ee46803a12 The send_delivery_status_to_service task was refactor to take the details of the notification and service api callback such that the task no longer needed to go to the database to provide the status update.
This PR removes the code that is no longer used. This extra step was necessary to keep the tasks backward compatible.
2018-03-19 17:38:20 +00:00
Rebecca Law
22c296b0ef Merge pull request #1780 from alphagov/send-service-callback-if-sent_at_is-None
Send service callback if sent at is none
2018-03-19 16:32:15 +00:00
Rebecca Law
fdfd6838a6 Fix error message.
The id in the message is referring to a notification not a service
2018-03-19 15:24:59 +00:00
Rebecca Law
cd2d85f2a3 Updates after code review.
- Remove print
- Update exception message.
2018-03-19 14:08:38 +00:00
Rebecca Law
0dc50190b2 Throw an exception whenever we updated a notification to technical failure.
If this is happening we want to know about it.
2018-03-16 17:18:44 +00:00
Rebecca Law
c9477a7400 When a notification is timed out in the scheduled task that may happen because the notification has not been sent.
Which means the sent_at date for the notification could be empty causing the service callback to fail.

- Allow code to work if notification.sent_at or updated_at is None
- Update calls to send_delivery_status_to_service to send the data encrypted so that the task does not need to use the db.
2018-03-16 14:47:56 +00:00
venusbb
7e2947790f merged master and up migration version 2018-03-16 10:57:23 +00:00
venusbb
bb95a2784f Create schedueled job, fixed tests 2018-03-16 09:22:34 +00:00
venusbb
ea70c6454a Fine-tuning DB model and create taks for data migration
- Removed unused columns in ft_billing
- Create tasks for nightly data migration
2018-03-14 17:07:33 +00:00
Rebecca Law
82cc6d6bef As it turns out the s3ftp used to mount the s3 bucket to our ftp server puts the file on s3 more than once. So the SNS topic is triggered more than once.
We need to deal with this, it's ok when updating a notification status from delivered to delivered. But the DailySortedLetter counts are being doubled.
Adding the file_name to the table as a unique key to get around this issue. It will mean we have multiple rows for each billing_day, but that's ok we can aggregate that.
This will also give us a way to see which file created which count.
2018-03-14 17:04:58 +00:00
Katie Smith
41a9f5a06e Change format of the letter response file we expect
We were previously expecting the letter response files to be in the
format of 'NOTIFY.<datetime>.RSP.TXT' but the response files we receive
use '-' in the filenames instead of '.' which was causing an error when
we tried to get the date from the filename.
2018-03-14 09:25:51 +00:00
Katie Smith
79b5a735e2 Ensure update letter notification status always handles temporary failure
In the 'update-letter-notifications-statuses' task we want to ensure
that temporary failures are always handled, regardless of whether the
response file we receive contains unknown Sorted statuses or not.
2018-03-14 09:25:51 +00:00
Rebecca Law
68d658086b Merge pull request #1759 from alphagov/fix-bug-timeout-notifications
Fix the bug in timeout notifications.
2018-03-13 09:34:33 +00:00
Rebecca Law
144356f096 Fix the bug in timeout notifications.
When the notification is timedout by the scheduled task if the service is expecting a status update, that update to the service would fail.
A test has been added.
2018-03-12 12:15:03 +00:00
Katie Smith
4f7dd1d258 Delete job statistics tasks
The tasks are no longer being used, so can be deleted safely:
* record_initial_job_statistics
* record_outcome_job_statistics
* timeout-job-statistics

The test file for the statistics tasks was deleted in a previous commit.
2018-03-12 10:48:46 +00:00
Leo Hemsted
ea2b0dfbc9 set processing_started in before earlier jobs are processed
process_incomplete_jobs loops through jobs processing them in a single
task. This means that if the job statuses are all 'error', and then the
process_incomplete_jobs task fails, the later jobs in the list that
never got picked up won't have their status set back to in progress, or
their processing_started time - so will be stuck in 'error' forever.

Instead, we set the job statuses to in progress and the start time to
now before we process any - so if the incomplete_jobs task fails later,
the jobs will be picked up (again) by the check_job_statuses task in
half an hour's time
2018-03-09 17:20:26 +00:00
Leo Hemsted
64bb94af9e set job status to error in the check_job_status scheduled task
the process_incomplete_jobs task runs through all incomplete jobs in
a loop, so it might not get a chance to update the processing_started
time of the last job before check_job_status runs again (every minute).
So before we even trigger the process_incomplete_jobs task, lets set
the status of the jobs to error, so that we don't identify them for
re-processing again.
2018-03-09 16:42:58 +00:00
Leo Hemsted
f0ca3d40de reset job processing time when re-processing incomplete jobs
we might stop processing jobs mid-way through if, for example, a
deploy or downscale kills the box working on it. We have a scheduled
task that identifies any job that we started processing more than half
an hour ago that is still processing.

However, we encountered a bug where we triggered the
process_incomplete_job multiple times, because the processing_started
of the job was still set to half an hour ago. If we reset the
processing_started to the current time, then it won't get picked up by
future runs of the check_job_status scheduled task.
2018-03-09 16:30:50 +00:00