Skip to content

Commit

Permalink
freshen up files
Browse files Browse the repository at this point in the history
  • Loading branch information
stvnrlly committed Nov 17, 2023
1 parent 379140c commit 63952e3
Show file tree
Hide file tree
Showing 29 changed files with 72 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ updates:
directory: "/" # Location of package manifests
schedule:
interval: "daily"

2 changes: 0 additions & 2 deletions .github/workflows/adr-accepted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,3 @@ jobs:
--title "Add ADR ${{ steps.next.outputs.number }} to the repo" \
--body "This pull request was opened automatically because #${{ github.event.issue.number }} was closed after being marked as an approved ADR. It contains a markdown file capturing the ADR body at the time the issue was closed. Please verify that the markdown is correct before merging!" || true
gh pr merge $BRANCH --auto --squash || true
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ As part of a U.S. government agency, the General Services Administration (GSA)

This project is in the public domain within the United States, and applicable copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).

All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ As stated in [CONTRIBUTING](CONTRIBUTING.md), all contributions to this project

## Trademark

GSA owns, reserves, and retains all rights, title, and interest in all trademarks owned by GSA. The User does not acquire any right or interest of any kind in any GSA trademark because of their use of the Modified Version or any of the modifications made to the Work by GSA.
GSA owns, reserves, and retains all rights, title, and interest in all trademarks owned by GSA. The User does not acquire any right or interest of any kind in any GSA trademark because of their use of the Modified Version or any of the modifications made to the Work by GSA.
2 changes: 1 addition & 1 deletion docs/adrs/0002-how-to-handle-timezones.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ We've also identified the following areas as pieces of the application and
service that could be impacted by any timezone changes:

- Reports by day (or specific month/year)
- Jobs running at a reasonable time
- Jobs running at a reasonable time
- Job schedules (we want users to understand when things will happen)
- Scheduling sending of messages
- UI listing of time messages were sent
Expand Down
2 changes: 0 additions & 2 deletions docs/adrs/0004-designing-pilot-content-visibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,3 @@ Mockup of Option 1:

Mockup of Option 2:
![Option 2](https://github.com/GSA/notifications-api/assets/6556888/ea7442e4-745a-49d2-a90c-156cc6129356)


Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ _No response_

### Next Steps

#463
#463
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ At this time, services will pull directly from the organization's quota. We may

### Author

@stvnrlly, @ccostino, @tdlowden
@stvnrlly, @ccostino, @tdlowden

### Stakeholders

@amyashida
@amyashida

### Next Steps

Expand Down
19 changes: 14 additions & 5 deletions docs/all.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Onboarding](#onboarding)
- [Setting up the infrastructure](#setting-up-the-infrastructure)
- [Using the logs](#using-the-logs)
- [`git` hooks](#git-hooks)
- [Testing](#testing)
- [CI testing](#ci-testing)
- [Manual testing](#manual-testing)
Expand Down Expand Up @@ -231,6 +232,14 @@ Staging: https://logs.fr.cloud.gov/app/discover#/view/73d7c820-596e-11ee-a43a-09

Once in the view, you'll likely want to adjust the time range in the upper right of the page.

# `git` hooks

We're using [`pre-commit`](https://pre-commit.com/) to manage hooks in order to automate common tasks or easily-missed cleanup. It's installed as part of `make bootstrap` and is limited to this project's virtualenv.

The configuration is stored in `.pre-commit-config.yaml`. In that config, there are links to the repos from which the hooks are pulled, so hop through there if you want a detailed description of what each one is doing.

We do not maintain any hooks in this repository.

# Testing

```
Expand Down Expand Up @@ -428,7 +437,7 @@ There is a Flask command to wipe user-created data (users, services, etc.).
The command should stop itself if it's run in a production environment, but, you know, please don't run it
in a production environment.
Running locally:
Running locally:
```
flask command purge_functional_test_data -u <functional tests user name prefix>
Expand All @@ -445,7 +454,7 @@ cf run-task notify-api "flask command purge_functional_test_data -u <functional
For these, we're using Flask commands, which live in [`/app/commands.py`](../app/commands.py).
This includes things that might be one-time operations! If we're running it on production, it should be a Flask
This includes things that might be one-time operations! If we're running it on production, it should be a Flask
command Using a command allows the operation to be tested, both with `pytest` and with trial runs in staging.
To see information about available commands, you can get a list with:
Expand Down Expand Up @@ -473,7 +482,7 @@ that both end up at `persist_notification`, which writes to the database, and `p
which enqueues the sending.
For CSV uploads, the CSV is first stored in S3 and queued as a `Job`. When the job runs, it iterates
through the rows, running `process_job.save_sms` to send notifications through `persist_notification` and
through the rows, running `process_job.save_sms` to send notifications through `persist_notification` and
`provider_tasks.deliver_sms`.
# Writing public APIs
Expand Down Expand Up @@ -667,7 +676,7 @@ For tasks that should happen before other stuff, there's a priority queue. Platf
can set templates to use this queue.
Currently, this queue doesn't do anything special. If the normal queue is very busy, it's
possible that this queue will be faster merely because it's shorter. By the same logic, a
possible that this queue will be faster merely because it's shorter. By the same logic, a
busy priority queue is likely to be _slower_ than the normal queue
## Celery scheduled tasks
Expand Down Expand Up @@ -814,7 +823,7 @@ Assuming that you have followed all steps to set up localstack successfully (see
- Go to settings and set the organization for your service to 'Broadcast services' (scroll down to platform admin)
- Go to settings and set your service to 'live' (scroll down to platform admin)
5. Run your app 'locally'. I.e. run `make run-procfile` on this project and `make run-flask` on the admin project
6. Sign in. Verify you are running with localstack. I.e., you do NOT receive a text message on sign in. Instead,
6. Sign in. Verify you are running with localstack. I.e., you do NOT receive a text message on sign in. Instead,
you see your authentication code in green in the api logs
7. Go to send messages and upload your csv file and send your 100000 messages
Expand Down
4 changes: 2 additions & 2 deletions docs/localstack.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ How to Use Localstack in Your Development Work

### Add LOCALSTACK_ENDPOINT_URL to Your .env File (One-Time)

* Find the value in the sample.env file (# LOCALSTACK_ENDPOINT_URL=http://localhost:4566).
* Find the value in the sample.env file (# LOCALSTACK_ENDPOINT_URL=http://localhost:4566).
* Copy and uncomment it into your .env file

### Run with Localstack (Recurring)
Expand All @@ -41,4 +41,4 @@ You should be able to send an SMS message in the UI and observe it in the dashbo
over a period of five minutes. And you should not receive a text message.

NOTE: You will still be prompted for a 2FA code when you log in. To get the code, look in the notification-api
logs for "AUTHENTICATION_CODE:".
logs for "AUTHENTICATION_CODE:".
2 changes: 1 addition & 1 deletion migrations/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S
datefmt = %H:%M:%S
4 changes: 2 additions & 2 deletions migrations/versions/0025_notify_service_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def upgrade():
template_history_insert = """INSERT INTO templates_history (id, name, template_type, created_at,
content, archived, service_id,
subject, created_by_id, version)
VALUES (:template_id, :template_name, :template_type, :time_now,
VALUES (:template_id, :template_name, :template_type, :time_now,
:content, False, :service_id, :subject, :user_id, 1)
"""
template_insert = """INSERT INTO templates (id, name, template_type, created_at,
content, archived, service_id, subject, created_by_id, version)
VALUES (:template_id, :template_name, :template_type, :time_now,
VALUES (:template_id, :template_name, :template_type, :time_now,
:content, False, :service_id, :subject, :user_id, 1)
"""
email_verification_content = """Hi ((name)),\n\nTo complete your registration for GOV.UK Notify please click the link below\n\n((url))"""
Expand Down
14 changes: 7 additions & 7 deletions migrations/versions/0095_migrate_existing_svc_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,34 @@ def get_values_if_flag(permission, flag):
conn.execute(
"""
INSERT INTO service_permissions (service_id, permission, created_at)
SELECT id, 'sms', '2017-05-26 17:30:00.000000' FROM services
WHERE id NOT IN (SELECT service_id FROM service_permissions
SELECT id, 'sms', '2017-05-26 17:30:00.000000' FROM services
WHERE id NOT IN (SELECT service_id FROM service_permissions
WHERE service_id=id AND permission='sms')
"""
)

conn.execute(
"""
INSERT INTO service_permissions (service_id, permission, created_at)
SELECT id, 'email', '2017-05-26 17:30:00.000000' FROM services
WHERE id NOT IN (SELECT service_id FROM service_permissions
SELECT id, 'email', '2017-05-26 17:30:00.000000' FROM services
WHERE id NOT IN (SELECT service_id FROM service_permissions
WHERE service_id=id AND permission='email')
"""
)

conn.execute(
"""
INSERT INTO service_permissions (service_id, permission, created_at)
SELECT id, 'letter', '2017-05-26 17:30:00.000000' FROM services
SELECT id, 'letter', '2017-05-26 17:30:00.000000' FROM services
WHERE can_send_letters AND id NOT IN (SELECT service_id FROM service_permissions
WHERE service_id=id AND permission='letter')
"""
)
conn.execute(
"""
INSERT INTO service_permissions (service_id, permission, created_at)
SELECT id, 'international_sms', '2017-05-26 17:30:00.000000' FROM services
WHERE can_send_international_sms AND id NOT IN (SELECT service_id FROM service_permissions
SELECT id, 'international_sms', '2017-05-26 17:30:00.000000' FROM services
WHERE can_send_international_sms AND id NOT IN (SELECT service_id FROM service_permissions
WHERE service_id=id AND permission='international_sms')
"""
)
Expand Down
8 changes: 4 additions & 4 deletions migrations/versions/0139_migrate_sms_allowance_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ def upgrade():
"time_now": datetime.utcnow(),
}
insert_row_if_not_exist = """
INSERT INTO annual_billing
(id, service_id, financial_year_start, free_sms_fragment_limit, created_at, updated_at)
SELECT uuid_in(md5(random()::text)::cstring), id, :current_year, :default_limit, :time_now, :time_now
FROM services WHERE id NOT IN
INSERT INTO annual_billing
(id, service_id, financial_year_start, free_sms_fragment_limit, created_at, updated_at)
SELECT uuid_in(md5(random()::text)::cstring), id, :current_year, :default_limit, :time_now, :time_now
FROM services WHERE id NOT IN
(select service_id from annual_billing)
"""
conn.execute(text(insert_row_if_not_exist), input_params)
Expand Down
2 changes: 1 addition & 1 deletion migrations/versions/0156_set_temp_letter_contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def upgrade():
history_query = """
UPDATE templates_history t_history set service_letter_contact_id = (
SELECT service_letter_contact_id from templates
where service_letter_contact_id is not null
where service_letter_contact_id is not null
and id = t_history.id
and version = t_history.version
)
Expand Down
4 changes: 2 additions & 2 deletions migrations/versions/0171_add_org_invite_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def upgrade():
template_insert = """
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
:notify_service_id, :subject, :user_id, 1, :process_type, false)
"""
template_history_insert = """
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False,
:notify_service_id, :subject, :user_id, 1, :process_type, false)
"""

Expand Down
8 changes: 4 additions & 4 deletions migrations/versions/0191_ft_billing_pkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
def upgrade():
op.get_bind()
op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey")
sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY
sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY
(bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international, rate)"""
op.execute(sql)


def downgrade():
op.get_bind()
op.execute("ALTER TABLE ft_billing DROP CONSTRAINT ft_billing_pkey")
sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY
sql = """ALTER TABLE ft_billing ADD CONSTRAINT
ft_billing_pkey PRIMARY KEY
(bst_date, template_id, service_id, rate_multiplier, provider, notification_type, international)"""
op.execute(sql)
4 changes: 2 additions & 2 deletions migrations/versions/0265_add_confirm_edit_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def upgrade():
template_insert = """
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
:subject, :user_id, 1, :process_type, false)
"""
template_history_insert = """
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
:subject, :user_id, 1, :process_type, false)
"""

Expand Down
4 changes: 2 additions & 2 deletions migrations/versions/0285_default_org_branding.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

def upgrade():
op.execute(
"""UPDATE organisation SET email_branding_id = email_branding.id
"""UPDATE organisation SET email_branding_id = email_branding.id
FROM email_branding
WHERE email_branding.domain in (SELECT domain FROM domain WHERE domain.organisation_id = organisation.id)
"""
)

op.execute(
"""UPDATE organisation SET letter_branding_id = letter_branding.id
"""UPDATE organisation SET letter_branding_id = letter_branding.id
FROM letter_branding
WHERE letter_branding.domain in (SELECT domain FROM domain WHERE domain.organisation_id = organisation.id)
"""
Expand Down
6 changes: 3 additions & 3 deletions migrations/versions/0294_add_verify_reply_to_.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def upgrade():
template_insert = """
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
:subject, :user_id, 1, :process_type, false)
"""
template_history_insert = """
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
VALUES (:template_id, :template_name, :template_type, :time_now, :content, False, :notify_service_id,
:subject, :user_id, 1, :process_type, false)
"""

email_template_content = "\n".join(
Expand Down
6 changes: 3 additions & 3 deletions migrations/versions/0298_add_mou_signed_receipt.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ def upgrade():
insert_t = """
INSERT INTO templates (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, current_timestamp,
VALUES (:template_id, :template_name, :template_type, current_timestamp,
:content, False, :notify_service_id, :subject, :user_id, 1, :process_type, false)
"""
insert_th = """
INSERT INTO templates_history (id, name, template_type, created_at, content, archived, service_id, subject,
created_by_id, version, process_type, hidden)
VALUES (:template_id, :template_name, :template_type, current_timestamp,
VALUES (:template_id, :template_name, :template_type, current_timestamp,
:content, False, :notify_service_id, :subject, :user_id, 1, :process_type, false)
"""

for template in templates:
Expand Down
2 changes: 1 addition & 1 deletion migrations/versions/0303_populate_services_org_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def upgrade():
UPDATE services_history
SET organisation_id = :organisation_id
WHERE id = :service_id
AND version = (select max(version) from services_history sh2 where id = services_history.id);
AND version = (select max(version) from services_history sh2 where id = services_history.id);
"""
conn.execute(
text(history_sql),
Expand Down
4 changes: 2 additions & 2 deletions migrations/versions/0312_populate_returned_letters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def upgrade():
conn = op.get_bind()
sql = """
select id, service_id, reference, updated_at
from notification_history
from notification_history
where notification_type = 'letter'
and notification_status = 'returned-letter'"""
insert_sql = """
insert into returned_letters(id, reported_at, service_id, notification_id, created_at, updated_at)
insert into returned_letters(id, reported_at, service_id, notification_id, created_at, updated_at)
values(uuid_in(md5(random()::text)::cstring), :updated_at, :service_id, :id, now(), null)
"""

Expand Down
4 changes: 2 additions & 2 deletions migrations/versions/0320_optimise_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def upgrade():
# PLEASE NOTE: that if you create index on production you need to add concurrently to the create statement,
# however we are unable to do that inside a transaction like this upgrade method
ix_notifications_service_id_composite = """
CREATE INDEX ix_notifications_service_id_composite
CREATE INDEX ix_notifications_service_id_composite
on notifications (service_id, notification_type, notification_status, created_at)
"""
op.execute(ix_notifications_service_id_composite)

ix_notifications_notification_type_composite = """
CREATE INDEX ix_notifications_notification_type_composite
CREATE INDEX ix_notifications_notification_type_composite
on notifications (notification_type, notification_status, created_at)
"""
op.execute(ix_notifications_notification_type_composite)
Expand Down
Loading

0 comments on commit 63952e3

Please sign in to comment.