Commit Graph

262 Commits

Author SHA1 Message Date
Cliff Hill
31f946e5ba Fixed the new endpoint calculations, added unit tests to validate the
code.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-07-10 16:12:38 -04:00
Cliff Hill
56a208601e Hopefully this fixes Bev's issue.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-07-09 14:12:46 -04:00
Cliff Hill
c368d3d3f2 More import adjustments.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-07-02 16:00:58 -04:00
Cliff Hill
8708d8ddce Fixin' imports.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-07-02 15:57:14 -04:00
Cliff Hill
f95d3e0b99 Made changes I requested to be done.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-07-02 15:38:22 -04:00
Anastasia Gradova
47c8964766 fetch_notification_status_for_service_by_month
altered to use NotificationAllTimeView like
the other endpoints
2024-06-21 16:58:09 -06:00
Anastasia Gradova
d3d2610578 correct timedelta for midnight that offest
calculation for today
2024-06-21 14:38:54 -06:00
Anastasia Gradova
966f9b4050 moved generate_date_range to date_util
standardized the SQLAlchemy calls
refactored the endpoints in service/rest.py
2024-06-20 23:12:47 -06:00
Anastasia Gradova
fd37923294 Updated SQLAlchemy queries and API endpoints
for single database queries to improve
application performance.
2024-06-20 01:04:31 -06:00
Anastasia Gradova
0082ba3dd0 Updated sort order, endpoint defenition, and tests
for REQUESTED attribute
2024-06-06 22:11:24 -06:00
Anastasia Gradova
a5055a0cf9 Updated endpoints to use the
NotificationAllTimeView which is a view created
to merge notifiations and notification_history
2024-06-06 16:00:12 -06:00
Anastasia Gradova
227b9a3fc9 Merge branch 'main' into 1006-new-api-failed-and-delivered-messages-7-days 2024-06-05 11:47:55 -06:00
Anastasia Gradova
5fbad5bd69 Added endpoints for #1006 and #1007 2024-05-25 20:59:08 -06:00
Kenneth Kehl
905df17f65 remove datetime.utcnow() 2024-05-23 13:59:51 -07:00
Anastasia Gradova
5cd68e8081 New endpoints for #1006 and #1007 2024-05-22 13:33:32 -06:00
Aditi Anand
ad55eef5e9 Changes for sqlalchemy 2.0 2024-04-24 16:27:20 -04:00
Aditi Anand
420291ffee sqlalchemy 2.0 changes 2024-03-25 10:55:14 -04:00
Aditi Anand
8bc1091f73 fix for failing tests 2024-03-20 10:57:04 -04:00
Cliff Hill
bd705ed188 More cleanup.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:34 -05:00
Cliff Hill
9523cc1d97 Cleaning up with black, isort, flake8.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
7416de2a28 KeyType implemented.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:33 -05:00
Cliff Hill
69a9accfca Getting NotificationStatus implemented everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
f120641087 Getting permission types configured.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
985ad27b3e Getting imports right to use app.enums
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:32 -05:00
Cliff Hill
3982f061b6 Made enums.py for all the enums to avoid cyclic imports.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
ac9591ec7c More tweaks, trying to get tests to be clean.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:43:31 -05:00
Cliff Hill
820ee5a942 Cleaning up a lot of things, getting Enums used everywhere.
Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
2024-02-28 12:40:52 -05:00
Andrew Shumway
d0368695db Revert "Added flag to remove default sender from user list" 2023-11-06 11:49:17 -07:00
Andrew Shumway
e0522393df Added flag to remove default sender from user list 2023-10-15 16:28:25 -06:00
Kenneth Kehl
1ecb747c6d reformat 2023-08-29 14:54:30 -07:00
Kenneth Kehl
5a350560d7 notify-api-433b remove research mode 2023-08-25 12:09:00 -07:00
Kenneth Kehl
4940d5e93b notify-api-332 rename organisation 2023-07-10 11:06:29 -07:00
Kenneth Kehl
9f9e0a6ad8 notify-136 change financial year starting in april to calendar year (#278)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-06-14 16:19:11 -04:00
Kenneth Kehl
80c6c677db clean up remaining todays() 2023-05-31 10:07:27 -07:00
Kenneth Kehl
38461af5ae fix format 2023-05-31 17:57:24 -07:00
Kenneth Kehl
db0d829238 notify-281 fix time-sensitive tests 2023-05-31 17:52:16 -07:00
Kenneth Kehl
08c1ad75c8 notify-260 remove server-side timezone handling 2023-05-10 08:39:50 -07:00
Ryan Ahearn
e07b596857 Remove contact list db, dao, and s3 code 2023-04-12 15:01:24 -04:00
Kenneth Kehl
27d86c949a #224 remove crown (#228)
Co-authored-by: Kenneth Kehl <@kkehl@flexion.us>
2023-04-11 16:29:37 -04:00
Steven Reilly
ff4190a8eb Remove letters-related code (#175)
This deletes a big ol' chunk of code related to letters. It's not everything—there are still a few things that might be tied to sms/email—but it's the the heart of letters function. SMS and email function should be untouched by this.

Areas affected:

- Things obviously about letters
- PDF tasks, used for precompiling letters
- Virus scanning, used for those PDFs
- FTP, used to send letters to the printer
- Postage stuff
2023-03-02 20:20:31 -05:00
stvnrlly
9e7ee1c0f8 migrate bst_date to local_date 2022-11-21 11:49:59 -05:00
stvnrlly
b50cb4712f tz utility swap and many test updates 2022-11-10 12:33:25 -05:00
stvnrlly
9f37592b1e cleaner flake8 cleaning 2022-10-21 00:26:37 +00:00
stvnrlly
f5b5ecb661 flake8 fixes for rebased commits 2022-10-19 16:23:34 +00:00
stvnrlly
0186095920 swap out uk org types for us-specific org types 2022-10-11 20:27:49 +00:00
Ben Thorner
d153603c5c Remove redundant DAO function / consolidate tests
The tests were previously covering a shared function that's now
only used once, so I've inlined it and merged the tests together
with a common naming that's consistent with the code under test.
2022-05-19 14:12:28 +01:00
Katie Smith
807db037eb Update flake8 from 3.8.4 to 4.0.1
And adds `noqa` to some non-errors which are being flagged.
2022-03-02 15:52:18 +00:00
Ben Thorner
d406829b6c Tweak SMS alert to make it worth the effort
Currently we alert if a service wastes £16 of SMS. It may cost us
around that amount just to deal with the alert, especially if the
service refuses to clean up their data.

This bumps the threshold to something more alarming, which should
make it more reasonable to suspend the service if we can show that
they've already wasted public money. £160 seems like a reasonable
compromise between have wasted vs could waste.

Note: we previously compromised on 1000 [1] down from 63K [2]. I
think we can afford to go a little bit higher.

[1]: https://github.com/alphagov/notifications-api/pull/3234
[2]: https://github.com/alphagov/notifications-api/pull/3221
2022-02-25 10:37:56 +00:00
Ben Thorner
76da31c32a Remove redundant conditional for letter branding
This is no longer used when creating a service [1]. It was likely
added at a migration point when Admin _did_ specify branding.

[1]: 50c3c3e10c/app/main/views/add_service.py (L15-L22)
2021-12-16 17:54:33 +00:00
Rebecca Law
35b20ba363 Correct the daily limits cache.
Last year we had an issue with the daily limit cache and the query that was populating it. As a result we have not been checking the daily limit properly. This PR should correct all that.

The daily limit cache is not being incremented in app.notifications.process_notifications.persist_notification, this method is and should always be the only method used to create a notification.
We increment the daily limit cache is redis is enabled (and it is always enabled for production) and the key type for the notification is team or normal.

We check if the daily limit is exceed in many places:
 - app.celery.tasks.process_job
 -  app.v2.notifications.post_notifications.post_notification
 - app.v2.notifications.post_notifications.post_precompiled_letter_notification
 - app.service.send_notification.send_one_off_notification
 - app.service.send_notification.send_pdf_letter_notification

If the daily limits cache is not found, set the cache to 0 with an expiry of 24 hours. The daily limit cache key is service_id-yyy-mm-dd-count, so each day a new cache is created.

The best thing about this PR is that the app.service_dao.fetch_todays_total_message_count query has been removed. This query was not performant and had been wrong for ages.
2021-06-22 16:15:36 +01:00