Commit Graph

6850 Commits

Author SHA1 Message Date
Rebecca Law
b853c4cdf1 Rename dao method to be more consistent.
Fix sort.
Add one to job_row_number, rows start at 0 which would confus the user.
2019-12-27 10:27:59 +00:00
Rebecca Law
aabaa4a971 Added joins to template, job and user for returned letter query.
Added unit tests
Comleted endpoint to get returned letter details
2019-12-27 10:27:59 +00:00
Rebecca Law
606b2b6c84 Change the insert to use updated_at as the reported_at date 2019-12-27 10:27:59 +00:00
Rebecca Law
5482c03bca [WIP] 2019-12-27 10:27:59 +00:00
Rebecca Law
22851c4ef0 Migration script to populate the returned letters. 2019-12-27 10:27:59 +00:00
David McDonald
9c8f5f8343 Merge pull request #2689 from alphagov/coveralls
Remove coveralls
2019-12-24 14:54:46 +00:00
David McDonald
6a8c7c1455 Merge pull request #2687 from alphagov/inbound-sms-history
Add and write into Inbound sms history
2019-12-24 10:13:32 +00:00
David McDonald
f948555ca8 Do nothing on db conflict
For notification and notification_history we do an upsert. Here, as the
inbound_sms table is never updated, only inserted to once (signified by
lack of updated_at field), an upsert would be unnecessary.

Therefore, if for some reason the delete statement failed as part of
moving data into the inbound_sms_history table, we can simply just
ignore any db conflicts raised by a rerun of
`delete_inbound_sms_older_than_retention`.
2019-12-24 09:39:06 +00:00
David McDonald
542f3b23aa Remove coveralls
We don't use it anymore
2019-12-24 08:37:19 +00:00
Pea Tyczynska
f8ff2d121f Changes following review:
- Check if right keys in new history rows
- Improve model and get rid of old revision version
- Add updated migration file
- Test data when inserting into inbound sms history
2019-12-20 16:17:27 +00:00
Pea Tyczynska
448cd1e94e Integrate inbound history insert into delete inbound sms function 2019-12-20 16:16:29 +00:00
Pea Tyczynska
a6b4675ae7 Populate inbound sms history when deleting inbound sms 2019-12-20 16:16:29 +00:00
Pea Tyczynska
de9d1a41eb Create InboundSmsHistory model and table 2019-12-20 16:16:29 +00:00
Chris Hill-Scott
54fd83f21e Merge pull request #2685 from alphagov/strip-whitespace-sms
Remove extraneous spacing characters from text messages
2019-12-19 13:47:56 +00:00
David McDonald
20125cf81e Merge pull request #2686 from alphagov/integer
Set healthcheck timeout as integer
2019-12-19 11:04:14 +00:00
David McDonald
9de3a9ff43 Set healthcheck timeout as integer
Not allowed to be a non integer so have upped to 3 rather than going to
2 (fairly arbitrary choice).
2019-12-19 10:55:38 +00:00
David McDonald
f791b3b734 Merge pull request #2684 from alphagov/healthcheck
Up API health check timeout to 2.5 seconds
2019-12-19 10:22:01 +00:00
Chris Hill-Scott
462a621256 Remove extraneous spacing characters from text messages
Brings in:
- [x] alphagov/notifications-utils#680
2019-12-18 11:24:09 +00:00
David McDonald
5aaf109ae1 Up API health check timeout to 2.5 seconds
This was after we saw an instance of the API failing it's healthcheck
even though it was still healthy enough to serve requests to users.

This follows the change we've also made to template-preview and admin of
upping the health check timeout. Unlike those where we set it to be 10
seconds, we have been less allowing here and only chosen 2.5 seconds.
This was at suggestion of Toby from PaaS as the api should generally
have quicker response times and more annoyance might be created for
users if we let an instance stick around for 10 seconds where it was
unable to serve requests successfully.
2019-12-18 10:36:04 +00:00
Katie Smith
897ed66348 Merge pull request #2675 from alphagov/new-letter-tasks
Add new tasks for processing letters which have passed virus scan
2019-12-17 16:16:29 +00:00
David McDonald
13aebb48d6 Merge pull request #2683 from alphagov/failure-rates
Improve developer experience for zendesk ticket
2019-12-17 13:26:11 +00:00
David McDonald
61f1469a20 Improve developer experience for zendesk ticket
We don't need to log this as an exception. It's not an exception, it's
behaviour that is not ideal but is still expected so therefore I've
changed it to warn. Also it removes the email we get for the exception
which is not needed as we get the zendesk ticket instead.

I've also fixed the multiline string meaning the link to the runbook is
included in the zendesk ticket.
2019-12-17 11:47:23 +00:00
Chris Hill-Scott
d777cd8149 Merge pull request #2682 from alphagov/search-by-reference
Allow searching notifications by reference as well as recipient
2019-12-17 10:04:37 +00:00
Chris Hill-Scott
c573209d7e Stop guessing notification type
Before the search term was either:
- an email address (or partial email address)
- a phone number (or partial phone number)

Now it can also be:
- a reference (or partial reference)

We can take a pretty good guess, by looking at the search term, whether
the thing the user is searching by email address or phone number. This
helps us:
- only show relevant notifications
- normalise the search term to give the best chance of matching what we
  store in the `normalised_to` field

However we can’t look at a search term and guess whether it’s a
reference, because a reference could take any format. Therefore if the
user hasn’t told us what kind of thing their search term is, we should
stop trying to guess.
2019-12-16 13:43:38 +00:00
Katie Smith
cc2191c19f Add new tasks for sanitising precompiled letters
Added a task, `sanitise-letter`, that will be called from antivirus when
a letter has passed virus scan. This calls a new task in
template-preview which will sanitise the PDF.

A second new task, `process-sanitised-letter`, will be called from the
template preview task and deals with updating the notification and
moving it to the relevant bucket.
2019-12-16 11:55:09 +00:00
Katie Smith
8f144be29c Add config for new template preview task
Added the queue and task names for the new template preview task to the
config. Also added the new bucket name that template preview will use
for the sanitised letters to the config for all environments.
2019-12-16 11:30:56 +00:00
Chris Hill-Scott
8cb6907828 Allow searching by reference as well as recipient
We have a team who want to find emails that might have been sent to an
incorrect address. Therefore they can’t search by the correct address,
because it won’t match.

What they do have is the reference number of the user’s application,
which is also stored in the `client_reference` field on the
notification.

So when a user is searching we should also look at the client reference,
as well as the recipient, allowing the user to enter either in the
search box.
2019-12-16 11:02:07 +00:00
Rebecca Law
555e660a13 Merge pull request #2676 from alphagov/add-returned-letters-table
Add returned letters table
2019-12-13 14:13:28 +00:00
Leo Hemsted
8dfd565bed Merge pull request #2681 from alphagov/provider-tend-back
tend providers back
2019-12-13 10:15:55 +00:00
Leo Hemsted
b355fc4523 refactor shared functionality from provider priority logic 2019-12-13 10:03:23 +00:00
Leo Hemsted
31d1abd6d1 add task to move sms providers back towards shared load
we generally aim to share the load between the two providers equally
(more or less). When one provider has struggled, we deprioritise them,
this commit adds a function that gradually restores balance. It checks
every five minutes, if it's been more than an hour since the providers
were last changed then it adjusts them towards a 50/50 split. Except
it's not quite 50/50 due to #reasons (we want to slightly favour MMG),
it's actually 60/40. That's defined in a new dict in config.py.
2019-12-13 10:02:39 +00:00
Leo Hemsted
48a735c58c remove unused fixture 2019-12-13 10:02:39 +00:00
Leo Hemsted
42e6bd8b82 remove unused old file 2019-12-13 10:02:39 +00:00
Leo Hemsted
06ba549164 Merge pull request #2679 from alphagov/f-strings
fix log line typo
2019-12-13 10:02:29 +00:00
Rebecca Law
d330025447 Changed reported_at to a date and included audit columns. 2019-12-12 14:11:54 +00:00
David McDonald
10ea8c38cd Merge pull request #2680 from alphagov/alg
Catch `TokenAlgorithmError`
2019-12-12 10:34:39 +00:00
David McDonald
946ba993b5 Catch TokenAlgorithmError
Instead of letting it go uncaught and causing an error, we now show the
user an appropriate error message.
2019-12-12 10:23:28 +00:00
Rebecca Law
140cb65554 Return report_at date as a date not datetime. I haven't converted this date from UTC to BST because we always upload the returned-letters during business hours. 2019-12-11 14:41:35 +00:00
David McDonald
c17c9ad1c6 Merge pull request #2673 from alphagov/billing-bug
Bill `NOTIFICATION_PENDING` notifications
2019-12-11 13:35:25 +00:00
Leo Hemsted
cec44f60e3 fix log line typo
log lines didn't make sense because the arguments were the wrong way
round.

As an experiment to try and clean up some of our code a bit, this commit
adds f-strings. f-strings were added in python 3.6, as a way to clean
up, simplify, and improve the performance of `str.format`.
2019-12-11 13:22:28 +00:00
Pea M. Tyczynska
8f9930792a Merge pull request #2678 from alphagov/convert-uuid-to-str
Use .format instead of concatenation to avoid type issues
2019-12-11 12:10:20 +00:00
Pea Tyczynska
c00f82b81b Co-Authored-By: Chris Hill-Scott <me@quis.cc>
Use .format instead of concatenation to avoid type issues

Trying to concatenate uuid onto a string was throwing an error.

Also it is not possible to use uuid in parametrize statements
it seems as it messes up with running tests on multiple threads
2019-12-11 11:18:42 +00:00
Leo Hemsted
1555d218c9 Merge pull request #2671 from alphagov/letters-for-longer
process letters for 10 days when updating ft_notification_status
2019-12-11 09:50:33 +00:00
Rebecca Law
3908f2ad59 fix codestyle 2019-12-10 17:21:44 +00:00
Rebecca Law
c8364b4dc4 Add endpoint to return the summary data for returned letters.
Returning the count of letters that are returned for each report date.
2019-12-10 16:21:55 +00:00
David McDonald
5438a4c126 Remove duplicate test
This test is testing the same things as
`test_fetch_billing_data_for_day_bills_correctly_for_status`
2019-12-10 10:18:00 +00:00
David McDonald
fc8a9c184b Bill NOTIFICATION_PENDING notifications
SMS and emails may be marked as `NOTIFICATION_PENDING`. These will be
billed as they will have been sent to the provider and will eventually
turn to a final state such as `NOTIFICATION_DELIVERED` or
`NOTIFICATION_PERMANENT_FAILURE`.

This change will fix a discrepency on the billing page were the number
of messages being billed was less than the number of messages reported
as sent on a services dashboard when some of those messages were in a
pending state.

In reality, I don't think this bug would have had any longer affects for
incorrect billing as messages would not stay in the pending state for
too long and billing calculations would happen after that point.
2019-12-10 10:07:56 +00:00
Rebecca Law
40a0c62926 New endpoint to return a summary of returned letters for the service. 2019-12-09 17:27:18 +00:00
Rebecca Law
c8368d908b Update process_returned_letters task to insert or update the returned_letter table. 2019-12-09 16:23:09 +00:00
Rebecca Law
15762d5c22 Method to insert or update the returned-letters 2019-12-09 16:19:46 +00:00