Commit Graph

244 Commits

Author SHA1 Message Date
venusbb
d59a1f447a Progress: Today stats completed 2017-09-22 11:05:36 +01:00
venusbb
13c78d9b9d code style changed 2017-09-15 15:00:13 +01:00
venusbb
9de7ae11e8 filter the Notifications result by trial_service_mode 2017-09-15 14:40:56 +01:00
Rebecca Law
f624f4f033 Insert and update methods for service_sms_sender 2017-09-11 17:40:37 +01:00
Ken Tsang
d99ab329eb Refactored code to use inbound_number.number
- Removed filter on sms_sender for `dao_fetch_services_by_inbound_number`
2017-08-23 14:14:32 +01:00
Ken Tsang
5bb20e41b3 Update dao_fetch_services_by_ss_sender 2017-08-17 18:15:22 +01:00
Ken Tsang
902b28e00f Refactor to check active flag 2017-08-16 16:27:42 +01:00
Ken Tsang
c36423aac6 Refactor code for dao_fetch_servies_by_sms_sender to use inbound_numbers
This will need to be refactored after the deployment of api and admin and after the update script for existing services using inbound numbers has been executed.
2017-08-16 12:51:31 +01:00
Leo Hemsted
372b10f19c fix up tests to be internally consistent
notifications should always have at least one of job and api key, and
the key type should match the api key's key type (or be 'normal')
2017-08-02 15:35:56 +01:00
Rebecca Law
a01163d719 Merge pull request #1077 from alphagov/drop-template_stats-table
Remove the archived table template_statistics.
2017-07-12 10:41:32 +01:00
Rebecca Law
8a01a76e33 Remove the archived table template_statistics. The last time the table we updated was August 30 2016, it's safe to say we are done with it.
I updated the InboundSms and TemplateRedacted model to include an index in the db.
Dropped service_permissions.updated_at column since we are not auditting the table
2017-07-10 14:43:46 +01:00
Imdad Ahad
a9c1338873 Remove Notification, NotificationHistory status labels:
Replace labels by adding a key kwarg in the model for status.

We still need this as sqlalchemy attmempts to look for `notification_status`
on the model (Notification/NotificationHistory). To achieve true ORM mapping
(map status -> notification_status) we need the key kwarg.

More here:
http://docs.sqlalchemy.org/en/latest/core/metadata.html#sqlalchemy.schema.Column#key
2017-07-10 14:09:30 +01:00
Rebecca Law
50dbfec383 Merge pull request #1059 from alphagov/update-purge_function
Refactor order of delete statements
2017-07-07 15:32:29 +01:00
Ken Tsang
98cd838510 ken-use-only-new-service-permissions 2017-07-06 12:27:55 +01:00
Rebecca Law
f78ff4daac Refactor order of delete statements 2017-07-03 13:40:13 +01:00
Leo Hemsted
52debfb412 Load all template model relationships when archiving a service
Since the version classes hinge on delicately preserving the session,
we need to take lots of care to ensure that we don't accidentally flush
half-way through. By joinedloading the template_redacted beforehand,
we prevent a flush which would inadvertantly remove the Service object
from the session, while it's still waiting in line to be versioned.
2017-06-29 10:34:38 +01:00
Leo Hemsted
3a0bc01a55 fix service_delete function to clean up template_redacted objects properly 2017-06-28 17:19:53 +01:00
Leo Hemsted
8ad10261ec add tests for redact_template rest 2017-06-28 16:53:39 +01:00
Martyn Inglis
c57e2a6894 Merge branch 'master' into inbound-sms
Conflicts:
	app/notifications/receive_notifications.py
	tests/app/notifications/test_receive_notification.py
2017-06-01 15:56:33 +01:00
Leo Hemsted
1530908228 manually set sms_sender when creating service
sqlalchemy default doesn't appear to work correctly when there is a
difference between the DB schema and the code (ie: during a migration)
in this case, lets just set sms_sender ourselves.

we can't write unit tests for this because this only happens when the
db is in an inconsistent state 😩
2017-05-31 17:31:06 +01:00
Leo Hemsted
4a85818c34 add inbound sms table 2017-05-30 10:47:01 +01:00
Ken Tsang
7aca3d8f43 Remove flags process in service_dao.create_service 2017-05-26 12:04:16 +01:00
Ken Tsang
1375bbe400 Refactor schema to improve error response 2017-05-25 17:55:24 +01:00
Ken Tsang
f7a18f77cf Update model to cascade permissions assoc proxy 2017-05-25 17:48:09 +01:00
Ken Tsang
234312ece0 Update service permissions to ensure state in sync 2017-05-25 17:48:09 +01:00
Ken Tsang
8e3e31faaf Updated service DAO and API end points 2017-05-25 17:47:21 +01:00
Martyn Inglis
8dc7a86148 Merge branch 'master' into async-job-stats
Conflicts:
	app/dao/services_dao.py
2017-05-18 09:34:54 +01:00
Ken Tsang
54446d5f4d Add default permissions when creating a service 2017-05-17 14:18:12 +01:00
minglis
05a179c6ef Merge pull request #941 from alphagov/load-service-on-auth
Load service on auth
2017-05-17 10:49:00 +01:00
Martyn Inglis
83a1b1526e Merge branch 'master' into async-job-stats
Conflicts:
	app/notifications/notifications_ses_callback.py
2017-05-17 09:49:43 +01:00
Martyn Inglis
fd542024a3 Merge branch 'master' into load-service-on-auth 2017-05-12 16:14:44 +01:00
Martyn Inglis
889c650724 Whitespace 2017-05-12 13:09:59 +01:00
Martyn Inglis
4751673f43 Fixed service test that deletes all the things to delete the job stats too. 2017-05-12 13:08:09 +01:00
Imdad Ahad
048861b968 Add dao to get active users for service 2017-05-11 15:39:15 +01:00
Martyn Inglis
064b7436db Extra call to explicitly load API keys on service load - avoids extra calls later. 2017-05-05 15:22:21 +01:00
Leo Hemsted
7e52fa4d13 add new notification_status column to models.py
We now have a new column in the database, but it isn't being
populated. The first step is to make sure we update this column,
while still keeping the old enum based column up to date as well.

A couple of changes have had to happen to support this - one irritating
thing is that if we're ever querying columns individually, including
`Notification.status`, then we'll need to give that column a label,
since under the hood it translates to `Notification._status_enum`.
Accessing status through the ORM (i.e., my_noti.status = 'sending' or
similar) will work fine.
2017-05-04 17:24:28 +01:00
Rebecca Law
3e0221adec Change get_financial_year to return ending date as 1 microsecond earlier.
That way we can write the queries as between start and end dates, making it easier to read.
This makes more sense.
2017-05-02 10:00:47 +01:00
Rebecca Law
6dc336ad6c Created new queries to return the rate with the sum of billable units for the year totals.
Once we have the new columns in notifications table, the query will need to include the rate multiplier and if the number is international.
The monthly billing query will be built next.
2017-04-28 10:10:48 +01:00
Rebecca Law
9e175f42e8 Refactor to make code more readible. 2017-04-06 11:18:21 +01:00
Rebecca Law
0506bc3b0c Updated the fetch_stats_by_date_range to return test notifications if the start and end date are with in the last 7 days.
If the date range is with the last 7 days we query Notifcations.
If the date range is outside of the last 7 days we query NotificationHistory.
NotificationHistory does not persist notifications created with a test api key.
2017-04-04 16:34:20 +01:00
Rebecca Law
eee662e5be Make the code neater for the query. 2017-04-03 15:52:52 +01:00
Ken Tsang
5f945ab30e Refactored code, changed now to utcnow in test 2017-03-29 11:47:41 +01:00
Ken Tsang
af78efd137 Fix get_detailed_services BST 2017-03-29 11:03:28 +01:00
Imdad Ahad
36d52c6e42 Add template type to response and refactor 2017-03-08 12:01:38 +00:00
Imdad Ahad
8272a4388d Add dao method to get template stats per month in financial year for service 2017-03-08 12:01:38 +00:00
Rebecca Law
d36eec652d Removed unused code in services_dao, which led to looking some of the queries.
By removing the join to services for the fetch_stats_by_date_range_for_all_services and dao_fetch_todays_stats_for_all_services
queries we get a 30% and 25% performance improvement.
2017-03-01 17:12:29 +00:00
Imdad Ahad
73d5ce4f8b Add tests to verify correctness of the switching provider task 2017-02-24 12:23:39 +00:00
Chris Hill-Scott
cffd0c2c54 Remove weekly stats endpoints
The weekly stats endpoint wont be used once
https://github.com/alphagov/notifications-admin/pull/1109 has been
merged.

It has been replaced with a new monthly endpoint in
https://github.com/alphagov/notifications-api/pull/807
2017-02-08 13:16:41 +00:00
Chris Hill-Scott
0dfa4a93d5 Make sure status dictionary is assinged each time
The status dictionary was being assigned once, and then subsequent
uses of it were by reference. This meant that each template type was
pointing at the same dictionary, and updating one meant updating all.

This commit adds a dictionary comprehension, which gets evaluated once
for each template type, so each template type has its own `dict` of
statuses.

Before
--
```
Email     SMS       Letter
  |        |           |
{'sending':, 'failed', …}
```

After
--
```
Email                SMS                   Letter
   |                  |                      |
{'sending':,      {'sending':,            {'sending':,
'failed',          'failed',               'failed',
…}                 …}                      …}
```
2017-02-07 13:14:58 +00:00
Chris Hill-Scott
45b505f379 Split out handling of BST queries for reuse 2017-01-31 14:16:35 +00:00