diff --git a/doc/release/RELEASE-NOTES.md b/doc/release/RELEASE-NOTES.md index 83bf3506b..e6b872339 100644 --- a/doc/release/RELEASE-NOTES.md +++ b/doc/release/RELEASE-NOTES.md @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). The format is based on the `RELEASE-NOTES-TEMPLATE.md` file. + ## Release 1.16.0 ## Introduction @@ -17,7 +18,7 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html * *Describe scheme changes here.* ### Code/API changes -* *Describe code/API changes here.* +* [OSDEV-1100](https://opensupplyhub.atlassian.net/browse/OSDEV-1100) - Replaced all mentions of "facility" and "facilities" with the new production location naming in the Logstash app. Renamed `location` field in the production locations index to `coordinates`. ### Architecture/Environment changes * *Describe architecture/environment changes here.* @@ -26,8 +27,8 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html * *Describe bugfix here.* ### What's new -* [OSDEV-1105](https://opensupplyhub.atlassian.net/browse/OSDEV-1105) Contribution. Allow commas in list name and update error message. -* [OSDEV-272](https://opensupplyhub.atlassian.net/browse/OSDEV-272) Facility Claims Page. Implement ascending/descending and alphabetic sort on FE. +* [OSDEV-1105](https://opensupplyhub.atlassian.net/browse/OSDEV-1105) - Contribution. Allow commas in list name and update error message. +* [OSDEV-272](https://opensupplyhub.atlassian.net/browse/OSDEV-272) - Facility Claims Page. Implement ascending/descending and alphabetic sort on FE. ### Release instructions: * *Provide release instructions here.* @@ -43,8 +44,6 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html #### Migrations: * 0150_introduce_function_formatting_number_to_percent - adds add_percent_to_number to DB and drop drop_calc_column_func. -#### Scheme changes -* *Describe scheme changes here.* ### Code/API changes * [OSDEV-1004](https://opensupplyhub.atlassian.net/browse/OSDEV-1004) - The following changes have been made to the Logstash and OpenSearch services: diff --git a/src/logstash/indexes/facilities.json b/src/logstash/indexes/facilities.json deleted file mode 100644 index 8635d0c95..000000000 --- a/src/logstash/indexes/facilities.json +++ /dev/null @@ -1,161 +0,0 @@ -{ - "template": "facilities-template", - "index_patterns": [ - "facilities*" - ], - "mappings": { - "properties": { - "os_id": { - "type": "keyword" - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "name_local": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "description": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "address": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "url": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "sector": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "parent_company": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "product_type": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "facility_type": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "processing_type": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "number_of_workers": { - "properties": { - "min": { - "type": "integer" - }, - "max": { - "type": "integer" - } - } - }, - "location": { - "type": "geo_point" - }, - "minimum_order_quantity": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "average_lead_time": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "percent_female_workers": { - "type": "integer", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "affiliations": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "certifications_standards_regulations": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - }, - "country": { - "properties": { - "alpha_2": { - "type": "keyword" - } - } - }, - "claim_status": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } - } -} diff --git a/src/logstash/indexes/production_locations.json b/src/logstash/indexes/production_locations.json new file mode 100644 index 000000000..5b1db8449 --- /dev/null +++ b/src/logstash/indexes/production_locations.json @@ -0,0 +1,162 @@ +{ + "index_patterns": [ + "production-locations*" + ], + "template": { + "mappings": { + "properties": { + "os_id": { + "type": "keyword" + }, + "name": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "name_local": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "description": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "address": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "url": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "sector": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "parent_company": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "product_type": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "location_type": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "processing_type": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "number_of_workers": { + "properties": { + "min": { + "type": "integer" + }, + "max": { + "type": "integer" + } + } + }, + "coordinates": { + "type": "geo_point" + }, + "minimum_order_quantity": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "average_lead_time": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "percent_female_workers": { + "type": "integer", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "affiliations": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "certifications_standards_regulations": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + }, + "country": { + "properties": { + "alpha_2": { + "type": "keyword" + } + } + }, + "claim_status": { + "type": "text", + "fields": { + "keyword": { + "type": "keyword" + } + } + } + } + } + } +} diff --git a/src/logstash/pipeline/sync_facilities.conf b/src/logstash/pipeline/sync_production_locations.conf similarity index 53% rename from src/logstash/pipeline/sync_facilities.conf rename to src/logstash/pipeline/sync_production_locations.conf index 078b102ac..f95ba2ca5 100644 --- a/src/logstash/pipeline/sync_facilities.conf +++ b/src/logstash/pipeline/sync_production_locations.conf @@ -9,7 +9,7 @@ input{ tracking_column => "updated_at" tracking_column_type => "timestamp" schedule => "*/15 * * * *" - statement_filepath => "/usr/share/logstash/sql/sync_facilities.sql" + statement_filepath => "/usr/share/logstash/sql/sync_production_locations.sql" } } filter { @@ -22,8 +22,8 @@ filter { target => "product_type_value" } json { - source => "facility_type_value" - target => "facility_type_value" + source => "location_type_value" + target => "location_type_value" } json { source => "processing_type_value" @@ -34,55 +34,55 @@ filter { target => "number_of_workers_value" } ruby { - path => "/usr/share/logstash/scripts/facilities/name_local.rb" + path => "/usr/share/logstash/scripts/production_locations/name_local.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/description.rb" + path => "/usr/share/logstash/scripts/production_locations/description.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/url.rb" + path => "/usr/share/logstash/scripts/production_locations/url.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/sector.rb" + path => "/usr/share/logstash/scripts/production_locations/sector.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/parent_company.rb" + path => "/usr/share/logstash/scripts/production_locations/parent_company.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/product_type.rb" + path => "/usr/share/logstash/scripts/production_locations/product_type.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/facility_type.rb" + path => "/usr/share/logstash/scripts/production_locations/location_type.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/processing_type.rb" + path => "/usr/share/logstash/scripts/production_locations/processing_type.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/number_of_workers.rb" + path => "/usr/share/logstash/scripts/production_locations/number_of_workers.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/location.rb" + path => "/usr/share/logstash/scripts/production_locations/coordinates.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/minimum_order_quantity.rb" + path => "/usr/share/logstash/scripts/production_locations/minimum_order_quantity.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/average_lead_time.rb" + path => "/usr/share/logstash/scripts/production_locations/average_lead_time.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/percent_female_workers.rb" + path => "/usr/share/logstash/scripts/production_locations/percent_female_workers.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/affiliations.rb" + path => "/usr/share/logstash/scripts/production_locations/affiliations.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/certifications_standards_regulations.rb" + path => "/usr/share/logstash/scripts/production_locations/certifications_standards_regulations.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/country.rb" + path => "/usr/share/logstash/scripts/production_locations/country.rb" } ruby { - path => "/usr/share/logstash/scripts/facilities/claim_status.rb" + path => "/usr/share/logstash/scripts/production_locations/claim_status.rb" } mutate { copy => { "os_id" => "[@metadata][_id]" } @@ -95,7 +95,7 @@ filter { "sector_value", "parent_company_value", "product_type_value", - "facility_type_value", + "location_type_value", "processing_type_value", "number_of_workers_value", "longitude", @@ -120,9 +120,9 @@ output { } ssl => "${OPENSEARCH_SSL}" ssl_certificate_verification => "${OPENSEARCH_SSL_CERT_VERIFICATION}" - index => "facilities" + index => "production-locations" document_id => "%{[@metadata][_id]}" - template_name => "facilities_template" - template => "/usr/share/logstash/indexes/facilities.json" + template_name => "production_locations_template" + template => "/usr/share/logstash/indexes/production_locations.json" } } diff --git a/src/logstash/scripts/facilities/facility_type.rb b/src/logstash/scripts/facilities/facility_type.rb deleted file mode 100644 index 93abdddf2..000000000 --- a/src/logstash/scripts/facilities/facility_type.rb +++ /dev/null @@ -1,17 +0,0 @@ -def filter(event) - # Get the facility_type_value (assuming it's a field in the event). - facility_type_value = event.get('facility_type_value') - - # Check if the value exists (avoids potential nil error). - if !facility_type_value || !facility_type_value['matched_values'] - return [event] - end - - # Extract processing types and remove null values. - values = facility_type_value['matched_values'].map { |value| value[3] if value[3] != nil }.compact - - # Set the facility_type field only if there are non-null values. - event.set('facility_type', values) if values.any? - - return [event] -end diff --git a/src/logstash/scripts/facilities/affiliations.rb b/src/logstash/scripts/production_locations/affiliations.rb similarity index 100% rename from src/logstash/scripts/facilities/affiliations.rb rename to src/logstash/scripts/production_locations/affiliations.rb diff --git a/src/logstash/scripts/facilities/average_lead_time.rb b/src/logstash/scripts/production_locations/average_lead_time.rb similarity index 100% rename from src/logstash/scripts/facilities/average_lead_time.rb rename to src/logstash/scripts/production_locations/average_lead_time.rb diff --git a/src/logstash/scripts/facilities/certifications_standards_regulations.rb b/src/logstash/scripts/production_locations/certifications_standards_regulations.rb similarity index 100% rename from src/logstash/scripts/facilities/certifications_standards_regulations.rb rename to src/logstash/scripts/production_locations/certifications_standards_regulations.rb diff --git a/src/logstash/scripts/facilities/claim_status.rb b/src/logstash/scripts/production_locations/claim_status.rb similarity index 100% rename from src/logstash/scripts/facilities/claim_status.rb rename to src/logstash/scripts/production_locations/claim_status.rb diff --git a/src/logstash/scripts/facilities/location.rb b/src/logstash/scripts/production_locations/coordinates.rb similarity index 61% rename from src/logstash/scripts/facilities/location.rb rename to src/logstash/scripts/production_locations/coordinates.rb index 4b7d2c280..ce8c44f90 100644 --- a/src/logstash/scripts/facilities/location.rb +++ b/src/logstash/scripts/production_locations/coordinates.rb @@ -5,21 +5,21 @@ def filter(event) # Get the longitude value from the event data (assuming it's a field named 'longitude'). lon = event.get('longitude') - # Check if both latitude and longitude are present (avoid creating empty location data). + # Check if both latitude and longitude are present (avoid creating empty coordinates data). if !lat || !lon # If either is missing, return the event without modification. return [event] end - # Create a hash to store the location data (latitude and longitude). - location = { + # Create a hash to store the coordinates data (latitude and longitude). + coordinates = { 'lat' => lat, 'lon' => lon } - # Set a new field named 'location' within the event containing the location data. - event.set('location', location) + # Set a new field named 'coordinates' within the event containing the coordinates data. + event.set('coordinates', coordinates) - # Return the modified event with the added location field. + # Return the modified event with the added coordinates field. return [event] end diff --git a/src/logstash/scripts/facilities/country.rb b/src/logstash/scripts/production_locations/country.rb similarity index 100% rename from src/logstash/scripts/facilities/country.rb rename to src/logstash/scripts/production_locations/country.rb diff --git a/src/logstash/scripts/facilities/description.rb b/src/logstash/scripts/production_locations/description.rb similarity index 100% rename from src/logstash/scripts/facilities/description.rb rename to src/logstash/scripts/production_locations/description.rb diff --git a/src/logstash/scripts/production_locations/location_type.rb b/src/logstash/scripts/production_locations/location_type.rb new file mode 100644 index 000000000..42cfc986e --- /dev/null +++ b/src/logstash/scripts/production_locations/location_type.rb @@ -0,0 +1,17 @@ +def filter(event) + # Get the location_type_value (assuming it's a field in the event). + location_type_value = event.get('location_type_value') + + # Check if the value exists (avoids potential nil error). + if !location_type_value || !location_type_value['matched_values'] + return [event] + end + + # Extract processing types and remove null values. + values = location_type_value['matched_values'].map { |value| value[3] if value[3] != nil }.compact + + # Set the location_type field only if there are non-null values. + event.set('location_type', values) if values.any? + + return [event] +end diff --git a/src/logstash/scripts/facilities/minimum_order_quantity.rb b/src/logstash/scripts/production_locations/minimum_order_quantity.rb similarity index 100% rename from src/logstash/scripts/facilities/minimum_order_quantity.rb rename to src/logstash/scripts/production_locations/minimum_order_quantity.rb diff --git a/src/logstash/scripts/facilities/name_local.rb b/src/logstash/scripts/production_locations/name_local.rb similarity index 100% rename from src/logstash/scripts/facilities/name_local.rb rename to src/logstash/scripts/production_locations/name_local.rb diff --git a/src/logstash/scripts/facilities/number_of_workers.rb b/src/logstash/scripts/production_locations/number_of_workers.rb similarity index 100% rename from src/logstash/scripts/facilities/number_of_workers.rb rename to src/logstash/scripts/production_locations/number_of_workers.rb diff --git a/src/logstash/scripts/facilities/parent_company.rb b/src/logstash/scripts/production_locations/parent_company.rb similarity index 100% rename from src/logstash/scripts/facilities/parent_company.rb rename to src/logstash/scripts/production_locations/parent_company.rb diff --git a/src/logstash/scripts/facilities/percent_female_workers.rb b/src/logstash/scripts/production_locations/percent_female_workers.rb similarity index 100% rename from src/logstash/scripts/facilities/percent_female_workers.rb rename to src/logstash/scripts/production_locations/percent_female_workers.rb diff --git a/src/logstash/scripts/facilities/processing_type.rb b/src/logstash/scripts/production_locations/processing_type.rb similarity index 100% rename from src/logstash/scripts/facilities/processing_type.rb rename to src/logstash/scripts/production_locations/processing_type.rb diff --git a/src/logstash/scripts/facilities/product_type.rb b/src/logstash/scripts/production_locations/product_type.rb similarity index 100% rename from src/logstash/scripts/facilities/product_type.rb rename to src/logstash/scripts/production_locations/product_type.rb diff --git a/src/logstash/scripts/facilities/sector.rb b/src/logstash/scripts/production_locations/sector.rb similarity index 100% rename from src/logstash/scripts/facilities/sector.rb rename to src/logstash/scripts/production_locations/sector.rb diff --git a/src/logstash/scripts/facilities/url.rb b/src/logstash/scripts/production_locations/url.rb similarity index 100% rename from src/logstash/scripts/facilities/url.rb rename to src/logstash/scripts/production_locations/url.rb diff --git a/src/logstash/sql/sync_facilities.sql b/src/logstash/sql/sync_production_locations.sql similarity index 99% rename from src/logstash/sql/sync_facilities.sql rename to src/logstash/sql/sync_production_locations.sql index 386dd0013..346badec7 100644 --- a/src/logstash/sql/sync_facilities.sql +++ b/src/logstash/sql/sync_production_locations.sql @@ -280,7 +280,7 @@ SELECT 1 ) ) - ) AS facility_type_value, + ) AS location_type_value, ( SELECT COALESCE(