From 966fcef966b51cb5532de355f4711d71066b89d2 Mon Sep 17 00:00:00 2001 From: RobertoJavaDev Date: Thu, 28 Nov 2024 09:13:01 +0100 Subject: [PATCH 1/7] fix: Changed enum with disaster type --- .../disasteralert/DisasterType.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java b/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java index d5a18517..46b87c07 100644 --- a/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java +++ b/src/main/java/pl/ateam/disasteralerts/disasteralert/DisasterType.java @@ -1,5 +1,21 @@ package pl.ateam.disasteralerts.disasteralert; public enum DisasterType { - STORM, FIRE, FLOOD, HURRICANE, BLIZZARD, DROUGHT, HEAT + STORM("Burza"), + FIRE("Pożar"), + FLOOD("Powódź"), + HURRICANE("Huragan"), + BLIZZARD("Śnieżyca"), + DROUGHT("Susza"), + HEAT("Upał"); + + private final String polishName; + + DisasterType(String polishName) { + this.polishName = polishName; + } + + public String getPolishName() { + return polishName; + } } From 815613a8f0db00363a6a6965b9cabc6efda2a345 Mon Sep 17 00:00:00 2001 From: RobertoJavaDev Date: Thu, 28 Nov 2024 09:14:52 +0100 Subject: [PATCH 2/7] fix: Added implementation to view controller --- .../pl/ateam/disasteralerts/web/DisasterViewController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java index ae17688c..932cd9c7 100644 --- a/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java +++ b/src/main/java/pl/ateam/disasteralerts/web/DisasterViewController.java @@ -41,6 +41,7 @@ public String showAddDisasterForm(Model model, @AuthenticationPrincipal AppUser model.addAttribute("disasterAddDTO", new DisasterAddDTO(null, null, null, null)); model.addAttribute("selectedLocation", appUser.getUserDTO().location()); model.addAttribute("googleApiKey", googleApiKey); + model.addAttribute("disasterTypes", DisasterType.values()); return "addDisaster"; } @@ -73,6 +74,7 @@ public String showDisasterList(Model model, @AuthenticationPrincipal AppUser use model.addAttribute("googleApiKey", googleApiKey); model.addAttribute("inLocationDisasterAmount", inLocationDisastersAmount()); + model.addAttribute("disasterTypes", DisasterType.values()); return "listDisasters"; } From 3589754cf1a9f044c36b370a8b924d2bec200925 Mon Sep 17 00:00:00 2001 From: RobertoJavaDev Date: Thu, 28 Nov 2024 09:15:32 +0100 Subject: [PATCH 3/7] fix: Changed html files --- src/main/resources/templates/addDisaster.html | 2 +- src/main/resources/templates/listDisasters.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/templates/addDisaster.html b/src/main/resources/templates/addDisaster.html index 25a4069e..a876aad5 100644 --- a/src/main/resources/templates/addDisaster.html +++ b/src/main/resources/templates/addDisaster.html @@ -23,7 +23,7 @@

Dodaj + th:text="${type.getPolishName()}"> diff --git a/src/main/resources/templates/listDisasters.html b/src/main/resources/templates/listDisasters.html index 2e088803..81b9eb00 100644 --- a/src/main/resources/templates/listDisasters.html +++ b/src/main/resources/templates/listDisasters.html @@ -91,7 +91,7 @@

Sprawdź Rodzaj zdarzenia
@@ -119,7 +119,7 @@

Sprawdź - + From ba5cfc300c5109efe2eb7726cac8118b91e9729f Mon Sep 17 00:00:00 2001 From: jkuznik Date: Thu, 28 Nov 2024 13:37:45 +0100 Subject: [PATCH 4/7] Fix first_name unique constraint --- src/main/resources/db/changelog/dev.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/dev.sql b/src/main/resources/db/changelog/dev.sql index 3d7d0ad7..5356d07b 100644 --- a/src/main/resources/db/changelog/dev.sql +++ b/src/main/resources/db/changelog/dev.sql @@ -150,4 +150,7 @@ CREATE TABLE sms_limits update_date TIMESTAMP WITHOUT TIME ZONE, limit_counter INT NOT NULL, CONSTRAINT pk_sms_limits PRIMARY KEY (id) -); \ No newline at end of file +); + +-- changeset jkuznik:1728934675080-26 +ALTER TABLE users DROP CONSTRAINT uc_users_first_name; \ No newline at end of file From 89ba8f4a2f8afbabde209e3d71c1bc89633cc310 Mon Sep 17 00:00:00 2001 From: jkuznik Date: Thu, 28 Nov 2024 13:43:59 +0100 Subject: [PATCH 5/7] The first thought is the best, first version should work --- src/main/resources/db/changelog/dev.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/db/changelog/dev.sql b/src/main/resources/db/changelog/dev.sql index 5356d07b..e5b7c7f7 100644 --- a/src/main/resources/db/changelog/dev.sql +++ b/src/main/resources/db/changelog/dev.sql @@ -153,4 +153,4 @@ CREATE TABLE sms_limits ); -- changeset jkuznik:1728934675080-26 -ALTER TABLE users DROP CONSTRAINT uc_users_first_name; \ No newline at end of file +ALTER TABLE users DROP CONSTRAINT uc_users_username; \ No newline at end of file From 4402659992ab943c3c40b7baa4a87716e7990fcd Mon Sep 17 00:00:00 2001 From: jkuznik Date: Fri, 29 Nov 2024 09:40:47 +0100 Subject: [PATCH 6/7] Fix time zone issue, increase readability self-host.yml --- .github/workflows/self-host-CD.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/self-host-CD.yml b/.github/workflows/self-host-CD.yml index 0a6452ad..0407e932 100644 --- a/.github/workflows/self-host-CD.yml +++ b/.github/workflows/self-host-CD.yml @@ -24,5 +24,15 @@ jobs: TWILIO_PHONE_NUMBER: ${{secrets.TWILIO_PHONE_NUMBER}} OPENAI_API_KEY: ${{secrets.OPENAI_API_KEY}} GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}} - DAY_SMS_LIMIT: 5 - run: sudo docker run -d -p 8080:8080 --name disaster-alert-container --network disaster-net -e TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID -e TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN -e TWILIO_PHONE_NUMBER=$TWILIO_PHONE_NUMBER -e OPENAI_API_KEY=$OPENAI_API_KEY -e GOOGLE_API_KEY=$GOOGLE_API_KEY -e DAY_SMS_LIMIT=$DAY_SMS_LIMIT jkuznik/disaster-alert \ No newline at end of file + DAY_SMS_LIMIT: ${{secrets.DAY_SMS_LIMIT}} + RISK_THRESHOLD: ${{secrets.RISK_THRESHOLD}} + run: sudo docker run -d --name disaster-alert-container --network disaster-net -p 8080:8080 \ + -e TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID \ + -e TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN \ + -e TWILIO_PHONE_NUMBER=$TWILIO_PHONE_NUMBER \ + -e OPENAI_API_KEY=$OPENAI_API_KEY \ + -e GOOGLE_API_KEY=$GOOGLE_API_KEY \ + -e TZ=Europe/Warsaw \ + -e RISK_THRESHOLD=$RISK_THRESHOLD \ + -e DAY_SMS_LIMIT=5 \ + jkuznik/disaster-alert \ No newline at end of file From b4e948879fa112ad8dae4c60d6ae53205d29ef14 Mon Sep 17 00:00:00 2001 From: jkuznik Date: Fri, 29 Nov 2024 09:54:09 +0100 Subject: [PATCH 7/7] Increase readability - 2 attempt --- .github/workflows/self-host-CD.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/self-host-CD.yml b/.github/workflows/self-host-CD.yml index 0407e932..dbc1db4c 100644 --- a/.github/workflows/self-host-CD.yml +++ b/.github/workflows/self-host-CD.yml @@ -26,7 +26,8 @@ jobs: GOOGLE_API_KEY: ${{secrets.GOOGLE_API_KEY}} DAY_SMS_LIMIT: ${{secrets.DAY_SMS_LIMIT}} RISK_THRESHOLD: ${{secrets.RISK_THRESHOLD}} - run: sudo docker run -d --name disaster-alert-container --network disaster-net -p 8080:8080 \ + run: | + sudo docker run -d --name disaster-alert-container --network disaster-net -p 8080:8080 \ -e TWILIO_ACCOUNT_SID=$TWILIO_ACCOUNT_SID \ -e TWILIO_AUTH_TOKEN=$TWILIO_AUTH_TOKEN \ -e TWILIO_PHONE_NUMBER=$TWILIO_PHONE_NUMBER \