Commit Graph

207 Commits

Author SHA1 Message Date
venusbb
5482ee4fe7 - wrap apply_async parameter notification_id in a str() argument
- check if service_callback_api exist before putting tasks on queue
- create_service_callback_api in tests before asserting if send_delivery_status_to_service has been called.
2017-12-04 17:58:38 +00:00
venusbb
771ce9e2bc fixed code style 2017-12-01 22:24:53 +00:00
venusbb
a0fe5c6971 created dao to get notifications by references 2017-12-01 09:31:03 +00:00
Rebecca Law
e9a1cc5f83 Stop deleting the mapping tables. 2017-11-30 11:27:08 +00:00
Rebecca Law
8aa94af5d7 Stop populating the notification to sender mapping table when creating a notificaiton. 2017-11-29 16:47:23 +00:00
Alexey Bezhan
a5ca66a01b Update notification queries with new TemplateHistory join
Changes the queries to use `Notification.template` relationship instead
of `.template_history` and TemplateHistory model insteaad of Template.
2017-11-10 15:12:07 +00:00
Rebecca Law
f5e79302cd Remove NotificationStatistics
NotificationStatistics was added as a spike but didn't work out as expected. This is finally removing all that unused code.
I'll drop the table in the next PR
2017-11-01 15:02:50 +00:00
Rebecca Law
d671adc1eb Fix codestyle 2017-10-30 16:51:27 +00:00
Rebecca Law
db6668eb61 Added the notification_to_sms_sender mapping table to the purge notifications query 2017-10-30 15:17:01 +00:00
Rebecca Law
0887910b1b Get the sms sender from the notificaiton_sms_sender mapping table if that does not exist get the default sms sender to pass on to the sms provider. 2017-10-30 14:55:44 +00:00
Rebecca Law
4eec11b633 Added an optional parameter in the form for POST /v2/notifications/sms and /service/<service_id>/send-notification to pass in the SMS sender id.
The send_sms_to_provider still needs to use the SMS sender being passed in to the POST.

As part of https://www.pivotaltracker.com/story/show/152106587
2017-10-30 13:36:49 +00:00
Rebecca Law
76c8b15f59 Update the billable units with the page count from the response file for letter notifications. 2017-10-27 13:53:55 +01:00
Richard Chapman
543535e2af Process Incomplete Jobs Updates
Comments are PR review. Updated code style in a few places to make it
more consistent with other code, added tests for letters and emails
so they are testedt, refactored some database queries to dao file

- Fixed code style
- Refactored database queries to dao code
- Added tests for emails and sms.
2017-10-17 11:07:36 +01:00
Ken Tsang
1eaf6e089b Refactor code to make it clearer
- Added code in `delete_notifications_created_more_than_a_week_ago_by_type` to remove notifications to email_reply_to older than 7 days
- Added transactional to `delete_notifications_created_more_than_a_week_ago_by_type`
2017-10-11 12:26:58 +01:00
Ken Tsang
2c46f201b5 Purge noti to email reply to older than 7 days 2017-10-09 14:51:27 +01:00
Richard Chapman
068ecd80a1 Changes after review. Style changes to ensure consistency with the rest of the code base to ensure good maintainability in future. 2017-10-05 16:50:18 +01:00
Richard Chapman
7974e59eb7 Changes after review. Updates to style and import order to be more consistent with other code.
Added clarification to an error message to give better debugging information.
Removed using dao_get_reply_to_by_service_id in tests to be more consistent with other code and use the test db functions or remove the need for a call altogether making the code less complex.
2017-10-05 16:50:18 +01:00
Richard Chapman
d2168b7985 Added the mapping between notification and reply to email to the database and persisted the mapping when the request is received by the end point. the end point also checks if the reply to email id exists and if not returns an error. Also added tests to test the functionality. 2017-10-05 16:50:17 +01:00
Leo Hemsted
aaadf09562 add tests for new sched task 2017-09-26 12:03:06 +01:00
Leo Hemsted
b1928b928c update process_letter tests 2017-09-26 11:28:54 +01:00
Leo Hemsted
f3db920c71 remove jobs from letter api calls
we now no longer create a job. At the end of the post there is no
action, as we don't have any tasks to queue immediately - if it's a
real notification it'll get picked up in the evening scheduled task.

If it's a test notification, we create it with an initial status of
sending so that we can be sure it'll never get picked up - and then we
trigger the update-letter-notifications-to-sent-to-dvla task to sent
the sent-at/by.
2017-09-26 09:57:36 +01:00
Leo Hemsted
17ba8db97f remove jobs from letter api and make success/error ftp callback tasks
1. No longer create jobs when creating letters from api 🎉
2. Bulk update notifications based on the notification references after
   we send them to DVLA - either as success or as error
2017-09-26 09:57:35 +01:00
Leo Hemsted
7dd3c1df5a set letter notifications to pending while notify-ftp does its stuff
this means that if the task is accidentally ran twice (eg we autoscale
notify-celery-worker-beat to 2), it won't send letters twice.

Additionally, update some function names and config variables to make
it clear that they are referring to letter jobs, rather than all letter
content
2017-09-26 09:57:35 +01:00
Imdad Ahad
72de309b26 Make perf platform processing stats query the NotificationHistory table 2017-08-31 12:52:59 +01:00
Katie Smith
49a6bfc06b Send '0', not 'null', to perf platform if no notifications are sent 2017-08-30 16:02:30 +01:00
Katie Smith
132d65bc75 Add query to get processing time stats for performance platform
We are only interested in API notifications, not including test
messages. Letters are not included.
2017-08-30 14:40:10 +01:00
Leo Hemsted
ae683cad6e Merge pull request #1192 from alphagov/deps
update dependencies
2017-08-22 15:39:49 +01:00
Chris Hill-Scott
bdc935a8b1 Exclude test keys when searching by recipient
The activity page doesn’t show notifications sent with a test key.

However it _does_ when you search by recipient. This is confusing
and inconsistent.
2017-08-21 17:38:21 +01:00
Leo Hemsted
c2152f9cb8 remove billable-units endpoint
it wasn't used anywhere, and the return value changed when flask was upgraded
2017-08-21 10:57:15 +01:00
Imdad Ahad
f5e38a896c Update the last template usage query to check Notification table:
* Don't check the NotificationHistory table (this can cause a timeout)
* Check template actually exists first
2017-08-07 10:19:21 +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
Imdad Ahad
c8c47f44a9 Don't update older status in timeout notifications task 2017-07-10 14:09:30 +01:00
Imdad Ahad
f0ffbad77d Fix syncing issue with Notification statuses:
The timeout_notifications job runs daily and does not correctly
update both the status fields to keep them in sync.
2017-07-06 12:30:08 +01:00
Martyn Inglis
e3644bae96 Merge branch 'master' into template-query-to-not-limit-by-days 2017-06-16 14:06:56 +01:00
Martyn Inglis
1bc8073a83 Tried to make this clearer 2017-06-08 15:11:41 +01:00
Martyn Inglis
3702ebdd93 This is a bit gnarly. When querying the notifications table for template usage, we don't apply the days limit if we're trying to get exactly 7 days.
This is because 7days should be the amount of data in that table so don't restrict.

Note not all queries do this in the same way and a pivotal bug has been raised to align this. This is a bug fix as right now the numbers are out in prod.
2017-06-08 13:42:41 +01:00
Imdad Ahad
bad0ce3d86 Return personalisation in notification dump in search by to 2017-06-05 15:53:57 +01:00
Imdad Ahad
0631b6c988 Add dao to delete inbound sms after seven days 2017-06-02 16:10:27 +01:00
Chris Hill-Scott
9ada8b2753 Don’t 500 when searching with bad email address
In the future we might want to validate email addresses before
attempting to search by them. But for a first pass we can just return
no results when a user types in something that isn’t an email address
or phone number.

It definitely better than returning a 500.
2017-05-30 14:50:48 +01:00
Imdad Ahad
78c10b7d30 Search notification against normalised recipient with filter for status 2017-05-26 11:45:56 +01:00
Rebecca Law
b745e13a28 Merge branch 'master' into schedule-api-notification 2017-05-25 13:37:04 +01:00
Leo Hemsted
d23a92fbc0 Merge pull request #952 from alphagov/international-delivery-receipts
update delivery receipts for countries that return them
2017-05-25 13:13:49 +01:00
Rebecca Law
96b0e42959 Merge branch 'master' into schedule-api-notification
Conflicts:
	app/celery/scheduled_tasks.py
	tests/app/celery/test_scheduled_tasks.py
2017-05-24 13:21:22 +01:00
Martyn Inglis
aaa0f763a1 Updated delete notifications over a week old query
- PREVIOUS
based on status. so as we add new status we have some orphaned rows, as these delete queries would miss them

- NOW
based on type. In effect they do the same thing, deleting emails, sms or letters older than a week old irrespective of status. Can see is iterating on this to have more granularity say for letters, so split up. Also means that the delete action isn't so big, as we half the affected rows, by doing it by type.
2017-05-23 13:40:15 +01:00
Rebecca Law
76d0783c63 Add beat config for send-scheduled-notifications task to run every 15 minutes.
Added the missing commit to the update pending
2017-05-22 16:30:45 +01:00
Rebecca Law
9bfba52f53 Add pending flag to scheduled_notifications.
Set pending flag to false when the notification has been sent to provider task.
2017-05-22 15:07:16 +01:00
Rebecca Law
2e078f9fc8 Add scheduled task to send scheduled notifcations.
Fix the query to fetch scheduled notifications.
2017-05-16 13:47:22 +01:00
Rebecca Law
56f657de9b fix style 2017-05-16 11:04:55 +01:00
Rebecca Law
579227dfc1 Method to return scheduled notifications that are ready to send 2017-05-16 10:48:04 +01:00
Rebecca Law
f0e2713bef Add scheduled_for in the post notification request form.
Return scheduled for in get_notification requests.
2017-05-15 17:27:38 +01:00