Commit Graph

450 Commits

Author SHA1 Message Date
Nicholas Staples
d40d9f76d4 Purge functional tests command added with passing test.
Code quality fix.
2016-05-06 11:16:30 +01:00
Martyn Inglis
57e05feafb Updated the Provider stats and rates DAO objects to query based on the identifier in the ProviderDetails object.
- updated all tests
- changed teardown to leave provider details rows on end of individual tests
2016-05-06 09:09:47 +01:00
Nicholas Staples
f465066a69 Group by Notification Statistics added and all tests working.
Fixed tests for upgraded client.
2016-05-05 11:04:20 +01:00
Nicholas Staples
f71dbe9c0f Message limit added and all tests passing. 2016-04-29 10:36:59 +01:00
Adam Shimali
4e81695c84 Added limit_days filter to get notifications dao. 2016-04-28 16:51:19 +01:00
Chris Hill-Scott
d7f6bb9976 Align date range for template + notification stats
We were using two different queries to filter template stats to the past
7 days, plus today.

Since we’re storing both as short dates, we can now use the same query
for both.

0      | 1       | 2         | 3        | 4      | 5        | 6      | 7
-------|---------|-----------|----------|--------|----------|--------|-------
Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday | Monday

So if we are on Monday, the stats should include today, plus everything
back to last Monday.

Previously the template stats query was only going back to the Tuesday.

This should mean the numbers on the dashboard always line up.
2016-04-27 11:11:09 +01:00
Adam Shimali
886f302993 Removed unused code 2016-04-25 17:21:55 +01:00
Adam Shimali
24ea6f1637 Use short dates when selection notifications for deletion.
This means we will retain notifications for a full week and not
delete records that are 7 x 24 hours older than the time of the run of
the deletion task.

Also the task only needs to run once a day now, so I have changed
the celery config for the deletion tasks.
2016-04-25 16:12:46 +01:00
Nicholas Staples
3b1423a2ea Provider Statistics added.
Rates command added with a test.

Updated to include added migration.
2016-04-21 13:47:04 +01:00
Adam Shimali
054d8baa0a Changed notifications stats day column to date type from string. 2016-04-20 15:38:06 +01:00
Chris Hill-Scott
85d5c656f8 Merge pull request #241 from alphagov/get-notification-stats-last-7-days
Allow filtering of notification stats by days
2016-04-20 10:07:17 +01:00
Adam Shimali
a6a18c1a6f This approach uses part of sqlalchemy example history_meta code
adapted to recording inserts and updates.

This removes need to manually create history tables.

Our code still remains in control of when history records are
created.
2016-04-19 17:13:26 +01:00
Chris Hill-Scott
9c2c9435e3 Allow filtering of notification stats by days
https://www.pivotaltracker.com/story/show/117920839

On the dashboard we want to show counts of notifications sent in the
last 7 days, plus today. So the API enpoint needs to accept an argument
to limit how many days worth of statistics it will return.

This is a bit fiddly at the DAO level because the date is just stored as
a string.
2016-04-19 16:44:19 +01:00
Nicholas Staples
31978bd987 Added page_size parameter for notifications api. All tests passing.
Add page_size and total parameters to all calls for notifications.
2016-04-19 11:26:21 +01:00
Nicholas Staples
f681d40366 Character count added and tests passing.
Remove sql restriction for count to not be null.
2016-04-15 16:31:13 +01:00
Nicholas Staples
90f0505a3d Update limit to message_limit.
Further db changes and updates.

Remove traceback print out.

Fix bug in passing template id to a task.
2016-04-11 16:53:40 +01:00
Adam Shimali
4ed2e7f8f2 Fix for misunderstanding about date range required for templates
stats.

It should always be last n days, whether or not there is data.
2016-04-07 09:30:02 +01:00
Adam Shimali
3057641e40 Change sort order for templates from name to date using full timestamp
so that it would be most recently used at top.
2016-04-06 14:30:13 +01:00
Nicholas Staples
4d15409781 Successful notifications are deleted after a week now. All tests passing. 2016-04-05 11:07:21 +01:00
Adam Shimali
f6620792b5 Additional sort order by template name for template statistics. 2016-04-04 17:51:24 +01:00
Adam Shimali
0d06be05e1 [WIP] Added dao method and rest endpoint for getting template
statistics by service.

Some cosmetic changes to imports.

Added fix for job rest not correctly returning errors.
2016-04-04 14:38:54 +01:00
Nicholas Staples
fac34aff10 Added functionality to allow filtering by multiple arguments.
Removed commented out code.
2016-04-04 13:21:51 +01:00
Adam Shimali
ca9c886c3e [WIP] On create of notification. Upsert record for template stats
recording usages of template by day.
2016-03-31 15:57:50 +01:00
Martyn Inglis
268819284f Merge branch 'master' into capture-delivery-outcomes
Conflicts:
	tests/app/notifications/test_rest.py
2016-03-21 13:32:31 +00:00
Martyn Inglis
e0316d1881 Adds notification stats update into the callback process
- when a provider callback occurs and we update the status of the notification, also update the statistics table

Adds:
- Mapping object to the clients to handle mapping to various states from the response codes, this replaces the map.
- query lookup in the DAO to get the query based on response type / template type

Tests around rest class and dao to check correct updating of stats

Missing:
- multiple client callbacks will keep incrementing the counts of success/failure. This edge case needs to be handle in a future story.
2016-03-21 13:24:37 +00:00
Nicholas Staples
327f169575 Filtering added and tests working. 2016-03-21 12:37:34 +00:00
Martyn Inglis
69654f4209 Parking some code that updates stats when notification delivery happens 2016-03-15 14:40:42 +00:00
Martyn Inglis
1ff4ebad5c Merge branch 'master' into client-callbacks
Conflicts:
	app/notifications/rest.py
	tests/app/celery/test_tasks.py
2016-03-14 11:45:21 +00:00
Martyn Inglis
fd973179cc - Commit session on job update
- log at exception level
2016-03-14 11:34:09 +00:00
Martyn Inglis
62a7b8bcd0 Update notification status by message reference
- SES sends a reference to allow us to identify the notification
- use this to update status

If source of email is one of our internal emails (invites or validations) - don't try and update a notification.
2016-03-11 10:19:40 +00:00
Martyn Inglis
901d04605f Ad a reference to the model
- used if 3rd party needs to record an ID for reconciliation purposes
2016-03-11 09:40:35 +00:00
Martyn Inglis
f88f86a924 Endpoint to allow SES updates to occur
- update notification with delivery state
2016-03-10 17:29:17 +00:00
Martyn Inglis
1f22f2b7cc Updates to fire text integration:
- client updated to raise errors with fire text error codes/messages

New endpoint
- /notifications/sms/firetext
For delivery notifications to be sent to.
2016-03-10 15:40:41 +00:00
Martyn Inglis
fd7eb54d10 Merge branch 'master' into delete-expired-things
Conflicts:
	app/celery/tasks.py
	tests/app/celery/test_tasks.py
	tests/app/dao/test_notification_dao.py
2016-03-10 09:48:29 +00:00
Martyn Inglis
976a4c06e3 Renamed some files and fixed a bug on deleting the failed notifications 2016-03-10 09:34:27 +00:00
Martyn Inglis
c8a5366484 Scheduled tasks to clean up the database
- tasks run hourly
- uses celery beat to schedule the tasks

4 new tasks
- delete verify codes (after 1 day)
- delete invitations (after 1 day)
- delete successful notifications  (after 1 day)
- delete failed notifications (after 7 days)

Delete methods in the DAO classes
2016-03-09 17:46:01 +00:00
Martyn Inglis
61a0cf32c8 Ensure clients have rate limit enforced
- rate limiting is a hard number per day
- not limited in terms of rate of request
- limit is a single number held against the service
- every notification counts against the limit, regardless of type
- return a 429 if limit exceeded.
2016-03-09 11:06:37 +00:00
Martyn Inglis
67c4bd2263 Build rest endpoint to read service stats
- get stats by service id
- returns a list of stats objects

Not paginated - have 1 row per day.
2016-03-08 16:34:03 +00:00
Martyn Inglis
f5f50e00ff New notification stats table
- to capture the counts of things that we do
- initial commit captures when we create an email or sms

DOES NOT know about ultimate success only that we asked our partners to ship the notification

Requires some updates when we retry sending in event of error.
2016-03-08 15:23:19 +00:00
Martyn Inglis
ae395b490e Fixed bug where I forgot to update only the right job :-( 2016-03-04 15:54:43 +00:00
Martyn Inglis
c44aaf0fdc Capture the count of sent notifications for a job 2016-03-04 14:25:28 +00:00
Martyn Inglis
dd67b84f6d Merge branch 'fetch-notifications-endpoints' of github.com:alphagov/notifications-api into fetch-notifications-endpoints
Conflicts:
	app/dao/notifications_dao.py
2016-03-01 14:59:21 +00:00
Martyn Inglis
6d345c1dfc Fixed ordering of the notifications test
- was backwards
2016-03-01 14:58:27 +00:00
minglis
57d8aa2bfd Removed print statement 2016-03-01 14:38:54 +00:00
Martyn Inglis
c5a993ead1 Fetch endpoints for notifications
- includes check on token type to ensure clients can perform admin style fetches
2016-03-01 13:30:10 +00:00
Martyn Inglis
10a764a2c1 Renamed the header of the CSV to 'to' from 'number' to allow for email jobs
- added new columns to Job and Notification to capture the start/end dates accurately
2016-02-25 09:59:50 +00:00
Martyn Inglis
655beddba6 Fixed up the get_notitication endpoint
- returns a notification
2016-02-16 11:22:44 +00:00
Adam Shimali
17e5e70f6c [WIP] Added endpoints under /job for creating, updating and reading
notification status.
2016-02-09 14:17:42 +00:00
Adam Shimali
e5e049d735 Added service and template relationship to notification model.
This makes it more consistent with other model classes with respect
to marhmallow serialisation/deserialisation.
2016-02-09 12:48:27 +00:00
Adam Shimali
c7121be5a2 [WIP] New model class and dao for notification. This will be used for
recording status and outcome of sending notifications.
2016-02-09 12:03:40 +00:00