From a23bc1512262a65dd21609b21d638fe7e92c4b2b Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 2 Jul 2024 17:57:16 +0200 Subject: [PATCH 1/3] Use SQS_PREFIX not ES_PREFIX for queues --- app/models/concerns/indexable.rb | 13 ++++--------- app/models/user.rb | 10 +--------- config/application.rb | 11 ++++------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 975a36b41..1313ff3de 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -32,11 +32,11 @@ module Indexable elsif instance_of?(Event) OtherDoiJob.perform_later(dois_to_import) # ignore if record was created via Salesforce API - elsif instance_of?(Provider) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage") + elsif instance_of?(Provider) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage") send_provider_export_message(to_jsonapi.merge(slack_output: true)) - elsif instance_of?(Client) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage") + elsif instance_of?(Client) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage") send_client_export_message(to_jsonapi.merge(slack_output: true)) - elsif instance_of?(Contact) && !from_salesforce && (Rails.env.production? || ENV["ES_PREFIX"] == "stage") + elsif instance_of?(Contact) && !from_salesforce && (Rails.env.production? || ENV["SQS_PREFIX"] == "stage") send_contact_export_message(to_jsonapi.merge(slack_output: true)) end end @@ -105,12 +105,7 @@ def send_contact_export_message(data) # we use the AWS SQS client directly as there is no consumer in this app def send_message(body, options = {}) sqs = Aws::SQS::Client.new - queue_name_prefix = - if Rails.env.stage? - ENV["ES_PREFIX"].present? ? "stage" : "test" - else - Rails.env - end + queue_name_prefix = ENV["SQS_PREFIX"].present? ? ENV["SQS_PREFIX"] : Rails.env queue_url = sqs.get_queue_url(queue_name: "#{queue_name_prefix}_#{options[:queue_name]}").queue_url options[:shoryuken_class] ||= "DoiImportWorker" diff --git a/app/models/user.rb b/app/models/user.rb index 28ce6b601..379c805eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -146,15 +146,7 @@ def self.reset(username) ) url = ENV["BRACCO_URL"] + "?jwt=" + jwt reset_url = ENV["BRACCO_URL"] + "/reset" - title = if Rails.env.stage? - if ENV["ES_PREFIX"].present? - "DataCite Fabrica Stage" - else - "DataCite Fabrica Test" - end - else - "DataCite Fabrica" - end + title = ENV["BRACCO_TITLE"] subject = "#{title}: Password Reset Request" account_type = if user.instance_of?(Provider) diff --git a/config/application.rb b/config/application.rb index 08b83b6dc..efbd74a5d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -41,6 +41,7 @@ ENV["API_URL"] ||= "https://api.stage.datacite.org" ENV["CDN_URL"] ||= "https://assets.datacite.org" ENV["BRACCO_URL"] ||= "https://doi.datacite.org" +ENV["BRACCO_TITLE"] ||= "DataCite Fabrica" ENV["GITHUB_URL"] ||= "https://github.com/datacite/lupo" ENV["SEARCH_URL"] ||= "https://search.datacite.org/" ENV["VOLPINO_URL"] ||= "https://profiles.datacite.org/api" @@ -63,6 +64,7 @@ ENV["MG_DOMAIN"] ||= "mg.datacite.org" ENV["HANDLES_MINTED"] ||= "10132" ENV["REALM"] ||= ENV["API_URL"] +ENV["SQS_PREFIX"] || = "" module Lupo class Application < Rails::Application @@ -171,13 +173,8 @@ class Application < Rails::Application # set Active Job queueing backend config.active_job.queue_adapter = ENV["AWS_REGION"] ? :shoryuken : :inline - # use SQS based on environment, use "test" prefix for test system - if Rails.env.stage? - config.active_job.queue_name_prefix = - ENV["ES_PREFIX"].present? ? "stage" : "test" - else - config.active_job.queue_name_prefix = Rails.env - end + # use SQS based on environment or what has been defined + config.active_job.queue_name_prefix = ENV["SQS_PREFIX"].present? ? ENV["SQS_PREFIX"] : Rails.env config.generators { |g| g.fixture_replacement :factory_bot } From 0be9ae8588d7325eecd87b1d1a8b5b985dfc0968 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 2 Jul 2024 18:19:35 +0200 Subject: [PATCH 2/3] Remove trailing whitespace --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 379c805eb..8e7853e14 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -146,7 +146,7 @@ def self.reset(username) ) url = ENV["BRACCO_URL"] + "?jwt=" + jwt reset_url = ENV["BRACCO_URL"] + "/reset" - title = ENV["BRACCO_TITLE"] + title = ENV["BRACCO_TITLE"] subject = "#{title}: Password Reset Request" account_type = if user.instance_of?(Provider) From a97e293ebcf033247cbbfb9d8ac5a237d99add82 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Tue, 2 Jul 2024 18:22:34 +0200 Subject: [PATCH 3/3] Fix syntax error --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index efbd74a5d..0a1b45aa0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -64,7 +64,7 @@ ENV["MG_DOMAIN"] ||= "mg.datacite.org" ENV["HANDLES_MINTED"] ||= "10132" ENV["REALM"] ||= ENV["API_URL"] -ENV["SQS_PREFIX"] || = "" +ENV["SQS_PREFIX"] ||= "" module Lupo class Application < Rails::Application