Commit Graph
83 Commits
Author SHA1 Message Date
Rebecca Law 8d042c36f4 Added a filter to restrict jobs older than a day from coming back.
This is only necessary because there is currently a job that is old, but had 1 row created a couple days later. So now there is 1 notifications for the job where the rest have been purged.
2019-11-08 10:37:37 +00:00
Rebecca Law 559faf3034 Fix the query.
Missing the where clause to join the two tables.... OOPS
2019-11-07 10:57:31 +00:00
Rebecca Law fd0c12912a Fix merge conflict with db upgrade 2019-11-06 10:54:38 +00:00
Rebecca Law db5a50c5a7 Adding a scheduled task to processing missing rows from job
Sometimes a job finishes but has missed a row in the middle. It is a mystery why this is happening, it could be that the task to save the notifications has been dropped.
So until we solve the missing let's find missing rows and process them.

A new scheduled task has been added to find any "finished" jobs that do not have enough notifications created. If there are missing notifications the job processes those rows for the job.
Adding the new task to beat schedule will be done in the next commit.

A unique key constraint has been added to Notifications to ensure that the row is not added twice. Any index or constraint can affect performance, but this unique constraint should not affect it enough for us to notice.
2019-11-06 10:49:46 +00:00
Leo Hemsted 975af113e4 Merge pull request #2639 from alphagov/remove-loadtesting-db-migration
remove loadtesting from the database
2019-11-06 10:49:46 +00:00
Rebecca Law 16fd12be6a If a job was created 7 days ago but scheduled to send 2 days later, the csv file will be deleted from S3 two days early.
For example if a file is uploaded on Aug 1, but scheduled for Aug 3, the csv file will be deleted 2 days before the notifications.
This will cause an error for on the jobs pages if the download report link is clicked.
2019-08-07 16:54:04 +01:00
Pea (Malgorzata Tyczynska)andChris Hill-Scott 957cf46748 Change apostrophes to prettier ones
Co-Authored-By: Chris Hill-Scott <me@quis.cc>
2019-07-22 10:48:34 +01:00
Pea Tyczynska e9de84beb0 Change content of error messages when letter job can't be cancelled.
This content was first done without help of content designer so
now it is improved with the help of one. New content is more
in line with the content in the admin app and more human-readable
and following GOV.UK standard.
2019-07-18 16:38:08 +01:00
Pea Tyczynska 8588d00657 Move tests closer to the code:
test can_letter_job_be_cancelled closer to the code
test dao_cancel_letter_job closer to the code
Mock out calls in cancel_letter_job to test just that method
2019-07-04 14:12:11 +01:00
Pea Tyczynska da65ba0c91 Return specific error messages if job cannot be cancelled
Also move checking if job can be cancelled to the endpoint
2019-07-01 15:44:39 +01:00
Pea Tyczynska cc966b1cf0 More checks and tests for cancelling a letter job 2019-06-28 15:57:39 +01:00
Rebecca Law 663b260777 Adding a cancel-letter-job endpoint to cancel a letter job. 2019-06-28 15:57:39 +01:00
Rebecca Law 6565c19a9b Adding new method to cancel a letter job. 2019-06-28 15:57:39 +01:00
Leo Hemsted b80beab76c use ft_notification_status and notifications for job statistics
we previously always read from NotificationHistory to get the
notification status stats for a job. Now, if the job is more than three
days old read from ft_notification_status table, otherwise read from
the notifications table (to keep live updates).
2018-12-12 13:27:19 +00:00
Leo Hemsted 63b3a3849f move job dao tests to use db.py instead of conftest directly 2018-12-12 12:59:55 +00:00
Pea Tyczynska f941b8b146 Use archived flag to see if job needs deleting from s3 bucket 2018-11-28 14:38:59 +00:00
Pea Tyczynska be6f37069b Change job selection dao to take flexible retention into account
Also test deleting jobs with flexible data retention

Also update tests for default data retention following logic
change: dao_get_jobs_older_than_data_retention now counts
today at the start of the day, not at a time when function runs
and updated tests reflect that
2018-11-28 14:37:43 +00:00
Rebecca Law bffa783e8f The ftp app once updated the status of a job, since we no longer call the task we can delete it. 2018-11-27 14:37:36 +00:00
Rebecca Law 7a16ac35bd Remove letter-jobs api
When we first built letters you could only send them via a CSV upload, initially we needed a way to send those files to dvla per job.
We since stopped using this page. So let's delete it!
2018-11-15 17:24:37 +00:00
Katie Smith c843e15f81 Stop populating job-statistics table when creating a job 2018-03-12 10:48:46 +00:00
Katie Smith b582f9f077 Delete Statistics DAO and some Jobs DAO functions
* Deleted the statistics DAO
  (this was used for the job statistics tasks)
* Deleted the functions in the jobs DAO which are no longer used
  (the functions that were used for the job-stats endpoints)
2018-03-12 10:48:46 +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
Leo Hemsted 08494ef206 more flake8. lots of unused imports and variables that didn't get used. i tried to preserve old variable names as comments when it looked like they were useful (eg when they were describing timestamps) 2017-11-28 17:23:09 +00:00
Leo Hemsted 043dee5a54 ensure no tests share the same name (using flake8's checker) 2017-11-28 14:28:01 +00:00
Ken Tsang 1b35731fb2 Refactor code
- updated dao_get_letter_jobs_by_status to dao_get_letter_job_ids_by_status to return array of strings
2017-08-24 11:57:46 +01:00
Ken Tsang b2b74e2b5d Fixed bug in letter job schedule 2017-08-23 13:22:07 +01:00
Ken Tsang bd79a6f770 Improved tests on letter jobs by status 2017-08-23 13:22:07 +01:00
Ken Tsang 18881cd580 Add scheduled letter jobs 2017-08-23 13:22:07 +01:00
Imdad Ahad ac9eb29707 Revert "Revert "1/4 Stop updating old Notification status column"" 2017-07-10 14:09:30 +01:00
Imdad Ahad b94a463911 Revert "1/4 Stop updating old Notification status column" 2017-07-06 12:30:08 +01:00
Imdad Ahad c7ea6ba116 Update tests to use set() otherwise is possible to fail 2017-07-06 12:30:07 +01:00
Rebecca Law 4fefec6aa3 New endpoints to return job stats.
Next step is to use the new endpoints in admin.
2017-06-13 10:56:03 +01:00
Rebecca Law cc04b5eb1d Added new endpoint for job statistics.
The structure has been flattened, so I need to create a new endpoint, start using that endpoint, then change the name back.
Added template_id and version to the get job stats by id.
2017-06-12 17:15:32 +01:00
Rebecca Law c7707873e4 Queries to get job statistics by job_id or by service_id. 2017-06-12 14:25:17 +01:00
Imdad Ahad 6b4597149f Add filter to get jobs to delete (sms, email, letter) 2017-06-06 16:01:27 +01:00
Chris Hill-Scott eb493f6817 Rename ‘One-off message’ to ‘Report’
See https://github.com/alphagov/notifications-admin/pull/1293/commits/7915845cb58bdacb90d693fbf3073d80e57fa0d2
2017-06-01 13:56:47 +01:00
Chris Hill-Scott 78d071f22f Ignore one-off messages in job list on dashboard
Same as how we ignore ‘send yourself a test’ messages (see:
d8467bfc3c). The dashboard gets clogged
up with one off messages otherwise, which affects:
- performance
- users ability to find their jobs
2017-06-01 12:30:47 +01:00
Martyn Inglis 8d4ccc3003 Updated jobs_Dao to make a job stats row when making a job - saves the ambiguity later as to whether the row exists. 2017-05-12 12:17:34 +01:00
Imdad Ahad 34de722e73 Add test to check for sent notification 2017-04-28 13:32:23 +01:00
Rebecca Law 7ba9b1d261 Update the update statements with the updated_at and sent_at timestamps. 2017-04-07 15:21:27 +01:00
Rebecca Law 4f6a66c904 Merge branch 'master' into update-job-status
Conflicts:
	app/dao/jobs_dao.py
	tests/app/dao/test_jobs_dao.py
2017-04-06 11:11:37 +01:00
Martyn Inglis 832005efef Updates to the delete CSV file job to reduce the number of eligible jobs in any run
- previously this was unbounded, so it got all jobs older then 7 days. In excess of 75,000 🔥
- this meant that the job took (a) a long time and (b) a lot memory and (c) doing the same thing every day

These changes mean that the job has a 2 day eligible window for jobs, minimising the number of eligible jobs in a run, whilst still retaining some leeway in event if it failing one night.

In principle the job runs early morning on a given day. The previous 7 days are left along, and then the previous 2 days worth of files are deleted:

so:
runs on
31st
30,29,28,27,26,25,24 are ignored
23,22 jobs here have files deleted
21 and earlier are ignored.
2017-04-05 16:23:41 +01:00
Rebecca Law c49217b1bf Update job status to ready to send, indicating the file for the job has been uploaded to S3. 2017-04-05 11:57:56 +01:00
Rebecca Law 140179b4b6 Create new task to build dvla file.
This will transform each notification in a job to a row in a file.
The file is then uploaded to S3.
The files will later be aggregated by the notifications-ftp app to send to dvla.

The method to upload the file to S3 should be pulled into notifications-utils package.
It is the same method used in notifications-admin.
2017-03-15 15:26:58 +00:00
Rebecca Law ea4214c7d5 Added a jobs_dao method to answer if the all the notifications have been created in the database for the given job. 2017-03-14 10:50:09 +00:00
Leo Hemsted d550893377 update tests to use create_user instead of sample_user
note that all of these tests have to be checked to ensure that they
still call through to notify_db_session (notify_db not required) to
tear down the database after the test runs - since it's no longer
required to pass it in to the function just to invoke the sample_user
function
2017-01-10 15:04:28 +00:00
Leo Hemsted 487554c025 use partial to make tests more legible 2016-10-11 14:40:23 +01:00
Leo Hemsted d8467bfc3c filter out test jobs from the GET /service/{}/job endpoint
this is so that the filtering, which we do on the admin side, is applied
before pagination - so that the pages returned are all valid displayable
jobs. unfortunately this means that another config value has to be copied
to the server side but it's not the end of the world
2016-10-11 14:30:40 +01:00
Chris Hill-Scott ac1f5fcc91 Fix impossible test notification
No way a notification can be processed before it’s created.
2016-10-10 13:12:50 +01:00
Chris Hill-Scott a2ea0db393 Make test easier to read
Explicity labelling what the numbers mean makes it easier to understand
what’s going on rather than having to refer back to the function call.
2016-10-10 13:12:40 +01:00