-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aa storm feature / alert logic #1420
Draft
Max-Z80
wants to merge
51
commits into
feature/add-new-AA-storm
Choose a base branch
from
aa-storm-feature/email-logic
base: feature/add-new-AA-storm
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 26 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
c0ef39b
create a bash file to be triggered by cron scheduler
038d34c
create basic file structure
e69bccd
basic version for the email logic
6ae7b69
use db to persist latest reports; revisit the logic
ddd4a08
restructure files for tests; test getLatestAvailableReports()
46536cf
add more tests
88e4e7f
add another test
6210ea7
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher a6aa3bc
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher 45d2537
Fix typeorm
ericboucher 0755431
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher 60b8902
pass status directly to email utility
Doniaab 46f5831
fix
Doniaab 2ba893e
WIP: update logic to new storage model
d35e38e
adapt logic to the new db model
Doniaab 4773e5b
build prism url, refacto
2408407
update lastTriggeredAt only when emails are sent
798b801
use list of emails instead of single email
5a420d6
fix date formating
81e0b35
fix entity type for array; add screenshot settings
ec514b9
fix windspeed
0c2affc
rename activated_64 to activated_89
afd47e3
install chrome and dependencies for puppeteer
Doniaab ac01fde
responsive padding
Doniaab 5a3382a
add env example
Doniaab 1b1326a
Update email.test.ts
ericboucher 76dbfd8
Fix linter
ericboucher d6faaa6
Update CI
ericboucher 93c1b8c
Update alerting.yml
ericboucher f623195
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher 27914df
Fix node20 typeorm error
ericboucher cf9e811
Allow any
ericboucher 4ffd06c
Update alert.test.ts
ericboucher 8979efc
Update alerting.yml
ericboucher a917b17
Update alerting.yml
ericboucher e8fc771
avoid blank capture and fix alert tests
Doniaab 2a6ec4f
store common types in common package
6f33c47
remove useless console.log
eb1ea64
test filterOutAlreadyProcessedReports()
ee0b60c
test worker
52c84a1
add basic readme.md
b0ac3f7
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher f09087d
Finalize status update
ericboucher ee94853
Update alert.test.ts.snap
ericboucher 951014b
Update common package
ericboucher f33d4d3
Merge branch 'feature/add-new-AA-storm' into aa-storm-feature/email-l…
ericboucher 18e540f
Use common types
ericboucher f9dba54
Remove FeaturePropertyDataType
ericboucher c235af7
Update frontend.yml
ericboucher 4e056a0
Updates for email alert (design, mailto link (#1432)
Doniaab 50f7a17
add docstring to worker
Doniaab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PRISM_ALERTS_EMAIL_HOST=smtp.gmail.com | ||
[email protected] | ||
PRISM_ALERTS_EMAIL_PASSWORD=test | ||
|
||
POSTGRES_PORT=5432 | ||
POSTGRES_HOST=localhost | ||
POSTGRES_USER=postgres | ||
POSTGRES_DB=postgres | ||
POSTGRES_PASSWORD="!ChangeMe!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
cd ~/prism-app/alerting | ||
|
||
# source secrets from AWS | ||
source ../api/set_envs.sh | ||
|
||
docker compose run --entrypoint 'yarn aa-storm-alert-worker' alerting-node 2>&1 | tee -a ~/prism-app/alerting/aa_storm_alert_worker.log | ||
|
||
## To set up the cron job, run the following command on the server: | ||
# crontab -e | ||
## and then add the following line to the crontab file: | ||
# 0 * * * * ~/prism-app/alerting/cron_aa_storm_alert_run.sh | ||
## This will run the alerting script every hour at minute 0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
alerting/migration/1738249210356-create-anticipatory-action-alerts-table.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class CreateAnticipatoryActionAlertsTable1738249210356 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "anticipatory_action_alerts" ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wadhwamatic we decided to store the alerts in a new table since the behavior was quite different. |
||
"id" SERIAL NOT NULL, | ||
"country" VARCHAR NOT NULL, | ||
"emails" VARCHAR[] NOT NULL, | ||
"prism_url" VARCHAR NOT NULL, | ||
"last_triggered_at" TIMESTAMPTZ, | ||
"last_ran_at" TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP, | ||
"last_states" jsonb, | ||
CONSTRAINT "PK_ad91cad659a3536465d564a4b3a" PRIMARY KEY ("id") | ||
)`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "anticipatory_action_alerts"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { run } from './aa-storm-alert/worker'; | ||
|
||
run(); |
65 changes: 65 additions & 0 deletions
65
alerting/src/aa-storm-alert/__snapshots__/alert.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`alert mechanism buildEmailPayloads() does not return a payload when detailed report indicates that activation48 is triggered but there is no pilot activated districts for 48kt exposed 1`] = `Array []`; | ||
|
||
exports[`alert mechanism buildEmailPayloads() does not return a payload when detailed report indicates that activation64 is triggered but there is no pilot activated districts for 64kt exposed 1`] = `Array []`; | ||
|
||
exports[`alert mechanism buildEmailPayloads() returns a payload when detailed report indicates that activation48 is triggered and pilot activated districts for 48kt winds are parts of the exposed districts 1`] = ` | ||
Array [ | ||
Object { | ||
"activatedTriggers": Object { | ||
"districts48kt": Array [ | ||
"Angoche", | ||
], | ||
"districts64kt": Array [], | ||
"windspeed": "", | ||
}, | ||
"base64Image": "", | ||
"cycloneName": "ELVIS", | ||
"cycloneTime": "2025-01-31T06:00:00Z", | ||
"email": "", | ||
"readiness": false, | ||
"redirectUrl": "", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`alert mechanism buildEmailPayloads() returns a payload when detailed report indicates that activation64 is triggered and pilot activated districts for 64kt winds are parts of the exposed districts 1`] = ` | ||
Array [ | ||
Object { | ||
"activatedTriggers": Object { | ||
"districts48kt": Array [], | ||
"districts64kt": Array [ | ||
"Namacurra", | ||
], | ||
"windspeed": "", | ||
}, | ||
"base64Image": "", | ||
"cycloneName": "ELVIS", | ||
"cycloneTime": "2025-01-31T06:00:00Z", | ||
"email": "", | ||
"readiness": false, | ||
"redirectUrl": "", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`alert mechanism buildEmailPayloads() returns a payload when detailed report indicates that readiness is triggered 1`] = ` | ||
Array [ | ||
Object { | ||
"activatedTriggers": Object { | ||
"districts48kt": Array [], | ||
"districts64kt": Array [], | ||
"windspeed": "", | ||
}, | ||
"base64Image": "", | ||
"cycloneName": "ELVIS", | ||
"cycloneTime": "2025-01-31T06:00:00Z", | ||
"email": "", | ||
"readiness": true, | ||
"redirectUrl": "", | ||
}, | ||
] | ||
`; | ||
|
||
exports[`alert mechanism buildEmailPayloads() returns no payload when detailed report indicates that activation is triggered but landfall already occured 1`] = `Array []`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not set this directly in the dockerfile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both approaches work, but in this case, defining the Chrome version in docker-compose.yml makes more sense. It simplifies updates if any issues arise and makes it easier to test different versions without rebuilding the image.