Commit Graph

93 Commits

Author SHA1 Message Date
Kenneth Kehl
905df17f65 remove datetime.utcnow() 2024-05-23 13:59:51 -07:00
Cliff Hill
db3761609b Job Status changed.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Kenneth Kehl
6f6061455c notify-162 delete incomplete s3 uploads (#276)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-05-23 11:31:30 -04:00
Ryan Ahearn
e07b596857 Remove contact list db, dao, and s3 code 2023-04-12 15:01:24 -04:00
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
Rebecca Law
d4009ffc52 Rename database management functions.
Rename @transactional to @autocommit.
Rename nested_transaction to tranaction.
2021-04-19 10:56:00 +01:00
Ben Thorner
a91fde2fda Run auto-correct on app/ and tests/ 2021-03-12 11:45:45 +00:00
Chris Hill-Scott
10e1fe6902 Revert "Don’t return jobs sent from contact lists"
This reverts commit 061c0a0050.
2020-12-01 15:18:32 +00:00
Chris Hill-Scott
061c0a0050 Don’t return jobs sent from contact lists
Now that we’re grouping jobs sent from contact lists within their
parent, they shouldn’t also be listed on the jobs page at the top level.
2020-12-01 11:56:34 +00:00
Chris Hill-Scott
f2314333b5 Merge pull request #2982 from alphagov/improve-efficiency-of-process-missing-rows
Improve efficiency of process missing rows task
2020-10-02 11:23:35 +01:00
Chris Hill-Scott
2fcde009ac Add an endpoint for stats about scheduled jobs
At the moment we display the count of scheduled jobs on the dashboard
by sending all the scheduled jobs to the admin app and letting it work
out the stats.

This is inefficient and, because the get jobs response has a page size
of 50, becomes incorrect if a service schedules more than 50 jobs.

This commit adds a separate endpoint which gives the admin app the stats
it needs directly and correctly.
2020-09-28 09:57:32 +01:00
Chris Hill-Scott
1d50bfaafc Remove unused column from query 2020-09-26 12:11:15 +01:00
Chris Hill-Scott
aace1bdd8a Allow 20 minutes before checking for missing rows
Since we’ve doubled the number of rows in a job, jobs can take twice as
long to insert all the notifications. We don’t check for missing rows
until we’re pretty confident that the original tasks have finished
processing. This means we need to double the time we wait to still be
as sure.
2020-09-26 11:38:38 +01:00
Pea Tyczynska
9c4205c7c6 Remove statsd decorators from dao functions
This done so that we do not use statsd on our http endpoint.
We decided we do not need metrics that this gave us. If we
change our minds, we will add Prometheus-friendly decorators
instead in the future.
2020-07-07 18:02:24 +01:00
Chris Hill-Scott
18ffccf8c9 Allow jobs to be filtered by contact list
Rather than showing all jobs that have been ‘copied’ from a contact list
I think it makes more sense to group them under the contact list. This
way it’s easier to see what messages have been sent to a given group of
contacts over time.

Part of this work means the API needs to return only jobs that have been
created from a given contact list, when asked.
2020-05-12 12:58:39 +01:00
Chris Hill-Scott
27a0ba1a65 Reformat arguments for readability
We want to add another argument here, and doing so would make the line
length too long with all the arguments on one line.

Also uses the * operator to enforce keyword-only arguments.
2020-05-12 12:57:54 +01:00
Rebecca Law
033bcb65d2 Update the dao_get_notification_outcomes_for_job to return the stats from either the notification table or the ft_notification_status table.
Currently if you visit the job page and the job is older than the data retention the totals on the page are all wrong because this query gets the counts from the notification table. With this change the data should always be correct. It also eliminates the need for looking at data retention. If the job is new and nothing has been created yet (i.e. the job hasn't started yet) then the page should show the correctly because the outcomes are empty (as expected), once the notifications for the jobs are created the numbers will start going up.
2019-12-30 16:17:00 +00:00
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
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)
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
2c79801c96 Return tuple from can_cancel_letter_job for clarity 2019-07-02 18:12:48 +01:00
Pea Tyczynska
090769a069 Pull cancellable job statuses from utils and fix tests 2019-07-01 15:45:03 +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
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
fd06924f3a Build a command to archive old jobs 2018-11-28 14:38:59 +00:00
Pea Tyczynska
50811c3b8e Archive job after corresponding file deleted from s3 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
Leo Hemsted
0efa223fb2 rename days_ago to midnight_n_days_ago
also add some more timezone boundary tests and minor code cleanup
2018-04-30 11:50:56 +01:00
Leo Hemsted
5e702449cb move days_ago to utils and make it tz aware
it's used in a few places - it should definitely know what timezones
are and return datetimes rather than dates, which are hard to work with
in terms of figuring out how tz aware they are.
2018-04-30 11:13:21 +01: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
Richard Chapman
d855b4e4ec Removed statsd from the api and use the statsd in the utils library.
The statsd code was added to the utils library a while ago, uses the
statsd from the util library and therefore consolidates the code into
once place.
2018-02-06 09:52:15 +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
18881cd580 Add scheduled letter jobs 2017-08-23 13:22:07 +01:00
Leo Hemsted
5d61b3644c add tests for new test-key handling 2017-08-02 11:14:05 +01:00
Leo Hemsted
13917c9c57 give test letter api notifications a different filename
so they can be distinguished on the frontend.

Also, some related cleanup:

* don't show test api letters on the frontpage
* make sure the subject is returned from the API for letters
* make sure the letter's address is returned for letters
2017-08-01 18:23:29 +01:00
Leo Hemsted
2ab105aaf4 add tests for letter api notifications 2017-07-27 16:43:55 +01:00
Imdad Ahad
a9c1338873 Remove Notification, NotificationHistory status labels:
Replace labels by adding a key kwarg in the model for status.

We still need this as sqlalchemy attmempts to look for `notification_status`
on the model (Notification/NotificationHistory). To achieve true ORM mapping
(map status -> notification_status) we need the key kwarg.

More here:
http://docs.sqlalchemy.org/en/latest/core/metadata.html#sqlalchemy.schema.Column#key
2017-07-10 14:09:30 +01:00