Commit Graph

815 Commits

Author SHA1 Message Date
Leo Hemsted
2793541b9c add billable_units column to notifications table
this replaces content_char_count, by performing the additional
steps to calculated billable units at insert time, rather than
read time. This means we can take into account whether the
service was in research mode or using a test api key when the
notification was sent :tada
2016-08-03 16:41:06 +01:00
Leo Hemsted
4ca23b2282 bring models in line with alembic
prevents new alembic scripts being pre-populated with index downgrades
2016-08-03 16:41:06 +01:00
Leo Hemsted
9a9ebf0886 filter on key types to avoid research mode (that dont actually send) 2016-08-03 16:41:04 +01:00
Leo Hemsted
1617f058e2 rework get_fragment_count to not use ProviderStatistics
use NotficationHistory instead. Unfortunately this means the SQL
gets a bit gnarly, as we have to repeat notifications_utils'
`get_sms_fragment_count` functionality inside a SELECT 😱
2016-08-03 16:29:30 +01:00
Martyn Inglis
e6347d99bd Merge branch 'master' into stats-db-updates
Conflicts:
	tests/app/conftest.py
2016-08-03 11:46:40 +01:00
Martyn Inglis
6eb210fae9 Merge branch 'master' into new-staging 2016-08-02 14:24:32 +01:00
Martyn Inglis
61aaa36f9b Rewiring how we do statsd
- decorater added to the DAO for notifications
2016-08-02 14:23:47 +01:00
Leo Hemsted
cb19e6769d Merge pull request #563 from alphagov/week-agg
New weekly aggregate function
2016-08-02 10:27:15 +01:00
Martyn Inglis
7a77312e04 Merge branch 'master' into new-staging 2016-08-02 09:02:32 +01:00
Leo Hemsted
717f1fd4a0 Merge branch 'master' into get-stats-for-today 2016-08-01 10:36:56 +01:00
Martyn Inglis
dbe34f46e6 Reordered imports 2016-07-29 10:15:34 +01:00
Martyn Inglis
44dffc9d22 Fixed config so properties are shared if possible 2016-07-29 10:15:34 +01:00
Martyn Inglis
9ec52eac02 New config style 2016-07-29 10:15:34 +01:00
Leo Hemsted
e5b0d568fa ensure stats returned for lifespan of service
even if they've never sent a notification for realsies
2016-07-28 15:24:21 +01:00
Leo Hemsted
8ad47481d7 add GET /service/<id>/notifications/weekly
moved format_statistics to a new service/statistics.py file, and
refactored to share code. moved tests as well, to try and enforce
separation between the restful endpoints of rest.py and the logic/
data manipulation of statistics.py
2016-07-28 13:48:39 +01:00
Leo Hemsted
444132ad66 rewrite weekly aggregate function to honor week boundaries
(and not use the stats table, and also be easier to read)
2016-07-26 17:23:59 +01:00
Leo Hemsted
48eff9a2ee add today_only flag to GET /service/:id
if both detailed=True and today_only=True are passed in, the stats
returned will only be for today.

if detailed is false or not specified, today_only has no effect
2016-07-26 14:35:29 +01:00
Leo Hemsted
fd96c854e1 add dao function to get notification stats for a server for toady only 2016-07-26 14:35:29 +01:00
Leo Hemsted
c81b30dba1 separated schemas once more into "with template" and "with personalisation"
"with personalisation" should only be used by the public notification api
"with template" should be used when we want template name, etc details.

also added an xfail test for correctly constructing notification
personalisation
2016-07-26 14:34:59 +01:00
Leo Hemsted
b28e7efd14 dont load template contents for job page
rename the notification_status_schema to make it apparent that it
involves the template, and then don't use it on the job page - the
job page doesn't do anything with the data. won't somebody think of
the cpu cycles! (also means it ignores problems with template
versions)
2016-07-26 14:34:59 +01:00
minglis
95af32f289 Merge pull request #556 from alphagov/fix-expired-token-error
Fix bug with expired token error response
2016-07-26 11:25:09 +01:00
Rebecca Law
ecd4b76080 Fix bug with expired token error response 2016-07-22 15:10:37 +01:00
Leo Hemsted
85c7aa4a40 Merge pull request #540 from alphagov/dashboard-notifications-api
detailed service api endpoint
2016-07-22 14:18:11 +01:00
Leo Hemsted
e6d85644e4 Merge pull request #552 from alphagov/update-utils-markdown-branding
Update utils for Markdown parsing + subbranding
2016-07-22 14:17:50 +01:00
Adam Shimali
cfd42a8a05 Statsd timings were being passed a timedelta instead for float for
milliseconds.

Bugfix for https://www.pivotaltracker.com/story/show/126852733
2016-07-22 12:13:24 +01:00
Chris Hill-Scott
68fd4947cb Update utils for Markdown parsing + subbranding
Markdown parsing (will be active but isn’t documented):
- [x] https://github.com/alphagov/notifications-utils/pull/54

Email sub branding (not used yet):
- [x] https://github.com/alphagov/notifications-utils/pull/55

Required modification to the email preview endpoint to make sure that
it only included the message and not any HTML.
2016-07-22 11:09:23 +01:00
Chris Hill-Scott
c38962e91a Only put a character limit on SMS notifications
We limit SMS to be a maximum of 495 characters at the point of an
API call being made.

We were also applying this limit to emails, which is wrong.
2016-07-21 16:33:21 +01:00
Leo Hemsted
2d1babf2bb 'detailed' flag on GET /service/<uuid>
if passed in, returns the service object with additional statistics
dictionary, which will be used in the admin app to populate dashboard
components. A new schema has been created for this to avoid clashing/
causing confusion with the existing schema, which is already used
for PUT/POST as well, and this schema can be easily tailored to
reduce ambiguity and lazy-loading
2016-07-21 14:04:25 +01:00
Leo Hemsted
67542280f5 remove unused user_id option from GET /service/<service_id> 2016-07-21 14:04:25 +01:00
Leo Hemsted
964ea1954c Merge pull request #538 from alphagov/services-speed-up
Speed up GET services endpoints
2016-07-21 14:03:44 +01:00
Rebecca Law
c8ad5362eb Moved mmg_url to configs.
Fix up the tests
2016-07-20 10:40:50 +01:00
Rebecca Law
aca23472e3 Use the new mmg api 2016-07-19 15:27:52 +01:00
Leo Hemsted
566ae798df Speed up GET services endpoints
Add additional relationships to exclude in the ServiceSchema metaclass.
Marshmallow by default lazily loads relationships when dumping, so any
relationships we know we won't need, we can exclude and avoid a DB call.
Lots of tables are linked to services, so it loads a lot of tables.
So don't load statistics tables, since they're clearly not needed.

We *do* however want to return the users for the service - they're used
in a few places. If we're returning all services, then we don't want to
make separate queries for these users, so we modify the services_dao
queries to load users the first time round. This should speed up all
GET queries to the services endpoints, most notably pages that get many
services (platform_admin, choose service, login)
2016-07-15 12:04:38 +01:00
Adam Shimali
9f9040869d Daily message limit imposed for service api calls. 2016-07-14 11:25:45 +01:00
Leo Hemsted
4ef084464d update notification_history table from notification_dao create/update functions
please ensure that any changes to notifications table happen through either dao_create_notification or dao_update_notification.
changed the notification status update triggered by the provider callbacks to ensure that sets updated_by and can update the history table.
also re-added the character_count so we can reconstruct billing data if needed.
2016-07-12 13:28:45 +01:00
Leo Hemsted
722699a72a Update notification_history table on insert/update of notifications
triggered via calls in dao_create_notification and dao_update_notification - if you don't use those functions (eg update in bulk) you'll have to update the history table yourself!
2016-07-12 13:27:31 +01:00
Leo Hemsted
47ef63adbe add notification_history table
table will be used for storing archival versions of notifications. It's an exact duplicate of notifications table, but with the following modifications:
* removed _personalisation
* removed to
* removed content_char_count

All foreign keys to other tables still exist. additionally, removed defaults (for id and created_at) since they'll be set when we create, and we should ensure that we don't forget about them when inserting/udpating this table.
2016-07-12 13:27:31 +01:00
Rebecca Law
f9004f983a Merge pull request #524 from alphagov/email-registered-users
Email registered users
2016-07-12 10:51:17 +01:00
Rebecca Law
8acb373f07 Merge pull request #523 from alphagov/fix-temp-failure-job
Add a lockmode for the update_notifications_status_by_id to prevent t…
2016-07-12 09:49:00 +01:00
Rebecca Law
b2da3f563b Merge branch 'master' into email-registered-users 2016-07-08 14:53:38 +01:00
Rebecca Law
1bfd25107b Add a lockmode for the update_notifications_status_by_id to prevent the timeout task from updating the same notification more than once.
This happens because more than one beat process was creating the timeout task, resulting in multiple workers running the same queries at the same time.
2016-07-08 14:48:07 +01:00
Rebecca Law
f4976539e4 Make email a required field for the email_data_schema. 2016-07-08 10:57:20 +01:00
Chris Hill-Scott
a8a556d02a Use PassThrough renderer
Implements and depends on:
- [ ] https://github.com/alphagov/notifications-utils/pull/49
2016-07-07 22:48:07 +01:00
Rebecca Law
36ecdca04c Add new email template for the GOV.UK Notify service, to send an email to users that register with the same email address.
Add a new endpoint to send the email.
2016-07-07 17:23:07 +01:00
Chris Hill-Scott
824085ead8 Bring in changes to template and CSV processing
Functional changes:
- adds the blue bar

Performance changes
- faster CSV processing

Depends on:

- [ ] https://github.com/alphagov/notifications-utils/pull/47
- [ ] https://github.com/alphagov/notifications-utils/pull/48

Also brings in some breaking changes, which do not affect utils (apart
from a weird import).
2016-07-07 15:44:30 +01:00
Rebecca Law
a1209ed9a4 Merge branch 'master' into fix-count 2016-07-06 14:45:10 +01:00
Rebecca Law
8bea8b6a8f Fix bug where all notifications were getting a type = email.
Includes a fix to notification and notification_statistics data.
2016-07-06 14:31:52 +01:00
Leo Hemsted
96513442fe notifications from test api keys dont send for real - a la research_mode
also added a bunch more tests around api keys to help ensure we're behaving in at least a consistent way
2016-07-05 16:29:53 +01:00
Leo Hemsted
a5e488c035 add test api key type 2016-07-05 16:20:02 +01:00
Leo Hemsted
242be97bfa remove reply_to_addresses from task kwargs
also added a test for aws_ses.send_email to prove it handles reply_to_address correctly
2016-07-04 17:29:41 +01:00