From c5e7d45d55a194ee6454f895f0591d06f85ecb17 Mon Sep 17 00:00:00 2001
From: QBai <31238531+qifeng-bai@users.noreply.github.com>
Date: Wed, 13 Nov 2024 12:58:26 +1100
Subject: [PATCH] 4.4.0 (4.3.1) release
Add userDetails base url : https://github.com/AtlasOfLivingAustralia/alerts/issues/326
Change logback format
---
.../alerts/files/4.3.1_update_records.sql | 67 +++++++++++++++++++
ansible/roles/alerts/tasks/main.yml | 19 ++++++
.../alerts/templates/alerts-config.properties | 1 +
ansible/roles/alerts/templates/logback.xml | 2 +-
4 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 ansible/roles/alerts/files/4.3.1_update_records.sql
diff --git a/ansible/roles/alerts/files/4.3.1_update_records.sql b/ansible/roles/alerts/files/4.3.1_update_records.sql
new file mode 100644
index 000000000..c5a998b3a
--- /dev/null
+++ b/ansible/roles/alerts/files/4.3.1_update_records.sql
@@ -0,0 +1,67 @@
+-- One-time update for the 4.3.1 release:
+
+-- 1. Annotations now uses its own template. To update the template, run the following query:
+update alerts.query set email_template='/email/annotations' where name='Annotations';
+
+-- 2. My Annotations now uses its own template. To update the template, run the following query:
+update alerts.query set email_template='/email/myAnnotations' where name='My Annotations';
+
+-- 3. Annotation on records for Dataset / collections / species now uses its "Annotation" template. To update the template, run the following query:
+
+ UPDATE alerts.query
+ SET email_template = '/email/annotations'
+ WHERE name LIKE 'New annotations on%';
+
+-- 4. Species List Annotations now share the same template with datasets. To update the template, run the following query:
+ -- 4.1 Update fire_when_change to false for species list queries
+
+ UPDATE alerts.property_path
+ SET fire_when_change = false
+ WHERE query_id IN (
+ SELECT query_id
+ FROM query
+ WHERE email_template = '/email/specieslists'
+ );
+
+ -- 4.2
+ update alerts.query set email_template="/email/datasets" where email_template='/email/specieslists';
+
+-- 5. Data Resource using Collectory Service now share the same template with datasets. To update the template, run the following query:
+ -- 5.1
+ -- update alerts.query set email_template="/email/datasets" where email_template='/email/dataresource';
+
+
+-- 6. Check base_url and query_path for the queries which name is "Annotations" and "My Annotations"
+
+-- if base_url is like:
+-- https://biocache.ala.org.au
+-- and query_path is like:
+-- /ws/occurrences/search?fq=user_assertions:*&q=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record
+--
+-- then they should be changed to:
+-- https://biocache.ala.org.au/ws
+-- and
+-- /occurrences/search?fq=user_assertions:*&q=last_assertion_date:[___DATEPARAM___%20TO%20*]&sort=last_assertion_date&dir=desc&pageSize=20&facets=basis_of_record
+
+ UPDATE alerts.query
+ SET
+ base_url = CONCAT(base_url, '/ws'), -- Add '/ws' to the end of base_url
+ query_path = SUBSTRING(query_path, 4) -- Remove '/ws' from the start of query_path
+ WHERE
+ query_path LIKE '/ws%'; -- Only apply if query_path starts with '/ws'
+
+
+-- Update some queries using api.test.ala.org.au and api.ala.org.au
+
+ UPDATE alerts.query
+ SET
+ base_url = 'https://biocache-ws-test.ala.org.au/ws'
+ WHERE
+ base_url LIKE 'https://api.test.ala.org.au/occurrences%';
+
+
+ UPDATE alerts.query
+ SET
+ base_url = 'https://biocache.ala.org.au/ws'
+ WHERE
+ base_url LIKE 'https://api.ala.org.au/occurrences%';
diff --git a/ansible/roles/alerts/tasks/main.yml b/ansible/roles/alerts/tasks/main.yml
index c1eec5d20..fc8e1b67e 100644
--- a/ansible/roles/alerts/tasks/main.yml
+++ b/ansible/roles/alerts/tasks/main.yml
@@ -15,6 +15,25 @@
- db
- alerts
+#- name: Copy 4.3.1 database records update SQL script
+# ansible.builtin.copy:
+# src: files/4.3.1_update_records.sql
+# dest: /tmp
+# tags:
+# - 4.3.1
+#
+#- name: Update queries records for 4.3.1
+# community.mysql.mysql_db:
+# name: "{{ alerts_db_name }}" # Database name to apply the SQL script to
+# state: import
+# target: "{{ item }}" # SQL script file
+# login_user: "{{ alerts_db_username }}" # Database username
+# login_password: "{{ alerts_db_password }}" # Database password
+# with_items:
+# - /tmp/4.3.1_update_records.sql
+# tags:
+# - 4.3.1
+
- name: ensure target directories exist [data subdirectories etc.]
file: path={{item}} state=directory owner={{ tomcat_user }} group={{ tomcat_user }}
with_items:
diff --git a/ansible/roles/alerts/templates/alerts-config.properties b/ansible/roles/alerts/templates/alerts-config.properties
index 9f644692c..c4ba3436b 100644
--- a/ansible/roles/alerts/templates/alerts-config.properties
+++ b/ansible/roles/alerts/templates/alerts-config.properties
@@ -48,6 +48,7 @@ collectory.baseURL={{ collectory_url | default('https://collections.ala.org.au')
collectoryService.baseURL: {{ collectory_service_url | default('https://collections.ala.org.au') }}
ala.userDetailsURL={{ alerts_userdetails_url | default(userdetails_url) | default('https://auth.ala.org.au/userdetails') }}/userDetails/getUserListFull
lists.baseURL={{ lists_url | default('https://lists.ala.org.au') }}
+userDetails.web.url ={{ user_details_url | default('https://auth.ala.org.au/userdetails') }}
# Emails
postie.enableEmail={{ enable_email | default('') }}
diff --git a/ansible/roles/alerts/templates/logback.xml b/ansible/roles/alerts/templates/logback.xml
index beb51f82d..6a4cc9164 100644
--- a/ansible/roles/alerts/templates/logback.xml
+++ b/ansible/roles/alerts/templates/logback.xml
@@ -19,7 +19,7 @@
10MB
- %d{yyyy-MM-dd HH:mm:ss.SSS} %5p --- %-40.40logger{39} : %m%n%wex
+ %clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr(%logger{39} [%file:%line]){cyan} %clr(:){faint} %m%n%wex