Commit Graph

234 Commits

Author SHA1 Message Date
Rebecca Law
21edf7bfdd Persist the processing time statistics to the database.
The performance platform is going away soon. The only stat that we do not have in our database is the processing time. Let me clarify the only statistic we don't have in our database that we can query efficiently is the processing time. Any queries on notification_history are too inefficient to use on a web page.
Processing time = the total number of normal/team emails and text messages plus the number of messages that have gone from created to sending within 10 seconds per whole day. We can then easily calculate the percentage of messages that were marked as sending under 10 seconds.
2021-02-26 07:49:49 +00:00
Pea Tyczynska
95deb5a52f Move DATETIME_FORMAT from app to app.utils
To avoid cyclical import issues
2020-12-18 17:39:35 +00:00
Pea Tyczynska
d506451d4f Include template id, too 2020-06-24 12:20:40 +01:00
Pea Tyczynska
4b2a0037e3 Get letter data for provided filenames 2020-06-23 17:45:05 +01:00
David McDonald
2f0b3a9636 Fix edge case in func test data purging for created_by_id
When running the purge command I found about 4 users who could not be
deleted because their user id was still referenced in the services table
as they had created the service yet they were not a member of that
service anymore.

I have fixed this by checking that if they are not a member but created
the service then we also delete the service for them.

Note, I've followed the previous convention of no tests for this
function. I've run it locally and executed the code path so there should
be no major flaws in the code. There is a small chance I wasn't able to
exactly replicate the state that existed in preview on my local but
hopefully it was close enough to be accurate.
2020-05-18 10:30:28 +01:00
David McDonald
df5ccae4c5 Add in positive logging case for purge command
This is useful so we can see that it's doing things, which case is being
hit and know that an empty terminal for an hour isn't a bad thing
2020-05-15 17:34:30 +01:00
Pea Tyczynska
5d6f2da155 Rename task from create_letters_pdf to get_pdf_for_templated_letter
In a separate PR we will have to delete vestigial create_letters_pdf
tasks that now only redirects to get_pdf_for_templated_letter.
2020-05-11 13:33:05 +01:00
Chris Hill-Scott
8c8c8b6328 Look in all parts of a letter template to find placeholders
Text messages have placeholders in their body.

Emails have them in their subject line too.

Letters have them in their body, subject line and contact block.

We were only looking in the the body and subject when processing a job,
therefore the thing assembling the letter was not looking in all the
CSV columns it needed to, because it hadn’t been told about any
placeholders in the contact block.

Fixing this means always making sure we use the correct `Template`
instance for the type of template we’re dealing with. Which we were
already doing in a different part of the codebase. So it makes sense to
reuse that.

Turns out we fixed the same bug for email subjects over 3 years ago:
3ed97151ee
2020-04-07 10:41:16 +01:00
Leo Hemsted
885f3122bd fix purge functional test data task
* it doesn't delete service email reply to or letter contacts, or
  contact lists. I don't think the contact lists will ever be an issue
  but it doesn't hurt to add it to the list of things to remove.
* it doesn't remove users from organisations before deleting the users

there may be more tables that link to Service that should be deleted,
but for now just add these ones that I could spot.
2020-03-30 17:45:29 +01:00
Leo Hemsted
ef6b7d564a make migrate-ft-notification-status command dates inclusive 2019-12-09 16:03:10 +00:00
Leo Hemsted
12da82c8ca fix end_date bug in migrate ft notification status command 2019-12-06 13:46:22 +00:00
Leo Hemsted
0448bca542 make create_nightly_notification_status_for_day take notification_type
the nightly task won't be affected, it'll just trigger three times more
sub-tasks.

this doesn't need to be a two-part deploy because we only trigger this
overnight, so as long as the deploy completes in daytime we don't need
to worry about celery task signatures
2019-12-05 14:43:33 +00:00
Leo Hemsted
766d46dda7 change migrate-data-to-ft-notification-status to use the existing task
saves the reimplementation of the big sql query
2019-12-05 14:43:33 +00:00
Rebecca Law
44b7b36acd Added a command to process a row from a job. 2019-09-26 14:19:09 +01:00
Leo Hemsted
5975ae2383 remove unneccessary duped lines
as per pr comments
2019-08-30 16:49:58 +01:00
Leo Hemsted
7811010e6c fix command name and get most recent data rather than oldest
fix query to order the right way

also remove debug prints that duplicate the formatted line below
2019-08-30 12:18:00 +01:00
Rebecca Law
1c94d6d24a Added command to populate data for annual billing based on last years values. 2019-08-30 12:17:59 +01:00
Leo Hemsted
9726edf68d bump utils
also remove the `read().splitlines()` pattern from csv.reader usage,
as it's redundant. also add .vscode to gitignore to accomodate my
hipster IDE choices, and add some lines to pytest.ini so just running
`py.test` uses some useful flags
2019-08-02 12:41:03 +01:00
Rebecca Law
b39da01573 Remove white space from email branding column. 2019-07-30 14:34:23 +01:00
Rebecca Law
467d9780c1 Add email and letter branding to the add organisation command (by csv file) 2019-07-29 15:35:54 +01:00
Leo Hemsted
9d415cd292 remove unnecessary unique index
primary key provides the same control. also catch the right exception
in the related command
2019-05-16 14:36:17 +01:00
Rebecca Law
3a421a0642 Added commit 2019-05-07 16:47:43 +01:00
Rebecca Law
439b11d9c2 Oops! I need notification_type and what not. 2019-05-07 16:46:09 +01:00
Rebecca Law
ef2bbbe683 Fix billable units
There was a situation where the SMS was sent, the request timed out we got a 503 so the notification was put on the retry queue. However, the provider got the notification and sent the message. This means we didn't set the billable_units on the notification and the service will not be billed.
This PR is to fix the notifications that we can accurrately update.
2019-05-07 16:31:12 +01:00
Rebecca Law
059bd52ee9 Leave go live user empty if it's not populated in spreadsheet 2019-04-24 15:44:57 +01:00
Rebecca Law
acd47f44f0 We want to continue not break. 2019-04-24 15:37:40 +01:00
Rebecca Law
bf42fa0c49 Use the csv.reader instead. 2019-04-24 11:56:44 +01:00
Rebecca Law
c989310ac5 New command to populate the go live user and date from the beta partners spreadsheet. 2019-04-24 10:56:50 +01:00
Rebecca Law
ba8ab45edf Command to populate the volume intentions for services. 2019-04-10 13:38:12 +01:00
Rebecca Law
aca2817184 The active flag in the query was excluding some services.
The active flag wasn't always used, plus a service should always be active on the first version of the service.
2019-04-08 11:24:45 +01:00
Rebecca Law
7cb51840b5 Ignore services where an organisation was not found. 2019-04-05 17:03:11 +01:00
Rebecca Law
1848c358f3 Command to associate services to organisations.
The association is based on the email address of the user that created the service, meaning we need to look at version 1 of the service_history.
Then use the existing methods to find the organisation by email address, then add the association.
2019-04-05 15:02:58 +01:00
Rebecca Law
38b8a00344 Fix boolean columns 2019-04-05 12:09:57 +01:00
Katie Smith
1f1c94be9d Add command to get notification details from 'zips sent' files
Added a command to get more detailed information about the letters that
are listed in the files of zip files sent that are stored on S3. This takes
one or more file paths as arguments and creates a CSV file with a row for each
letter.
2019-04-04 16:21:58 +01:00
Rebecca Law
2b36678a26 Populate data from file for organisation data
Finished the command to populate organistions and domains from a spreadsheet.
Should be a one time use thing.

fix codestyle
2019-04-04 16:04:18 +01:00
Rebecca Law
cb94f949a1 New command to iterate through the files on S3 and call record_daily_sorted_counts.
There are many files from early on that have not had the sorted counts recorded.
2019-03-26 15:49:21 +00:00
Katie Smith
510e6bd7bf Update print statement in command 2019-02-06 15:34:34 +00:00
Katie Smith
c36660708f Fix codestyle 2019-02-06 14:13:45 +00:00
Rebecca Law
53858473d0 Make the replace more specific 2019-02-06 14:08:16 +00:00
Rebecca Law
abc2dbb147 Fix update statement to be case insensitive. 2019-02-06 14:08:16 +00:00
Rebecca Law
9fe9187a19 New server command to remove .gsi from the email address of all users for a given service. 2019-02-06 14:08:16 +00:00
Leo Hemsted
d3d56a3224 separate nightly tasks and other scheduled tasks.
other tasks is anything that is run on a different frequency than
nightly
2019-01-18 15:36:53 +00:00
Pea Tyczynska
d36c4d8a78 Remove now unused methods that populated template usage redis cache 2019-01-15 14:38:45 +00:00
Pea Tyczynska
fd06924f3a Build a command to archive old jobs 2018-11-28 14:38:59 +00:00
Pea Tyczynska
1c4d2c7625 Update existing ft_notification_status data to get rid of repeats 2018-11-08 11:52:40 +00:00
Leo Hemsted
267c4fc07b bump requirements, fix pyflake8 things, unpin botocore/awscli 2018-11-07 13:39:08 +00:00
Katie Smith
0b5da2b8ad Update command to migrate data to ft_billing
Updated the 'migrate-data-to-ft-billing' command to populate the new
postage column of ft_billing. This will be populated with the
postage of the notification for letters, or 'none' for email or sms. We
need to ensure there are no null values in postage so that the postage
column can become part of the primary key later.

Also updated the query to get the right rate letter rate now that we are
updating rates in the letter_rates table.
2018-09-28 13:52:17 +01:00
Leo Hemsted
7496178156 populate historic notification postage data
sets all letters in notification history (and notifications) to
"second", so that there's no null letters for billing etc. Commits in
ten day chunks (up to ~30k letters)
2018-09-20 17:41:04 +01:00
Pea Tyczynska
b28ec8beda Use old monthly_billing-related routes for new functions 2018-07-30 11:33:15 +01:00
Pea Tyczynska
ca2b350a99 Remove references to monthly_billing table from api 2018-07-30 11:07:42 +01:00