Browse Source

CLDC-2652 Use new env vars (#2379)

* feat: use new env var names

* feat: update names

* feat: update test

* feat: update test
pull/2385/head v0.4.35
natdeanlewissoftwire 8 months ago committed by GitHub
parent
commit
452066a37c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/jobs/create_addresses_csv_job.rb
  2. 2
      app/jobs/data_export_xml_job.rb
  3. 2
      app/jobs/email_csv_job.rb
  4. 2
      app/jobs/email_missing_addresses_csv_job.rb
  5. 2
      app/jobs/scheme_email_csv_job.rb
  6. 2
      app/models/forms/bulk_upload_lettings/upload_your_file.rb
  7. 2
      app/models/forms/bulk_upload_sales/upload_your_file.rb
  8. 2
      app/services/bulk_update_from_csv/update_locations_from_csv_service.rb
  9. 2
      app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb
  10. 2
      app/services/bulk_upload/downloader.rb
  11. 2
      lib/tasks/data_export.rake
  12. 4
      lib/tasks/import_address_from_csv.rake
  13. 2
      spec/lib/tasks/correct_address_from_csv_spec.rb
  14. 4
      spec/lib/tasks/data_export_spec.rb
  15. 2
      spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

2
app/jobs/create_addresses_csv_job.rb

@ -14,7 +14,7 @@ class CreateAddressesCsvJob < ApplicationJob
filename = "#{['sales-logs-addresses', organisation.name, Time.zone.now].compact.join('-')}.csv" filename = "#{['sales-logs-addresses', organisation.name, Time.zone.now].compact.join('-')}.csv"
end end
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string)
Rails.logger.info("Created addresses file: #{filename}") Rails.logger.info("Created addresses file: #{filename}")

2
app/jobs/data_export_xml_job.rb

@ -2,7 +2,7 @@ class DataExportXmlJob < ApplicationJob
queue_as :default queue_as :default
def perform(full_update: false) def perform(full_update: false)
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_BUCKET"])
export_service = Exports::LettingsLogExportService.new(storage_service) export_service = Exports::LettingsLogExportService.new(storage_service)
export_service.export_xml_lettings_logs(full_update:) export_service.export_xml_lettings_logs(full_update:)

2
app/jobs/email_csv_job.rb

@ -20,7 +20,7 @@ class EmailCsvJob < ApplicationJob
filename = "#{[log_type, 'logs', organisation&.name, Time.zone.now].compact.join('-')}.csv" filename = "#{[log_type, 'logs', organisation&.name, Time.zone.now].compact.join('-')}.csv"
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string)
url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME)

2
app/jobs/email_missing_addresses_csv_job.rb

@ -18,7 +18,7 @@ class EmailMissingAddressesCsvJob < ApplicationJob
email_method = :send_missing_sales_addresses_csv_download_mail email_method = :send_missing_sales_addresses_csv_download_mail
end end
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string)
url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME)

2
app/jobs/scheme_email_csv_job.rb

@ -23,7 +23,7 @@ class SchemeEmailCsvJob < ApplicationJob
filename = "#{['schemes-and-locations', organisation&.name, Time.zone.now].compact.join('-')}.csv" filename = "#{['schemes-and-locations', organisation&.name, Time.zone.now].compact.join('-')}.csv"
end end
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string) storage_service.write_file(filename, BYTE_ORDER_MARK + csv_string)
url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME)

2
app/models/forms/bulk_upload_lettings/upload_your_file.rb

@ -56,7 +56,7 @@ module Forms
def storage_service def storage_service
@storage_service ||= if upload_enabled? @storage_service ||= if upload_enabled?
Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
else else
Storage::LocalDiskService.new Storage::LocalDiskService.new
end end

2
app/models/forms/bulk_upload_sales/upload_your_file.rb

@ -49,7 +49,7 @@ module Forms
def storage_service def storage_service
@storage_service ||= if FeatureToggle.upload_enabled? @storage_service ||= if FeatureToggle.upload_enabled?
Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
else else
Storage::LocalDiskService.new Storage::LocalDiskService.new
end end

2
app/services/bulk_update_from_csv/update_locations_from_csv_service.rb

@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateLocationsFromCsvService
end end
def call def call
s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
original_locations_csv = csv_from_path(@original_file_name, s3_service) original_locations_csv = csv_from_path(@original_file_name, s3_service)
updated_locations_csv = csv_from_path(@updated_file_name, s3_service) updated_locations_csv = csv_from_path(@updated_file_name, s3_service)

2
app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb

@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateSchemesFromCsvService
end end
def call def call
s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
original_schemes_csv = csv_from_path(@original_file_name, s3_service) original_schemes_csv = csv_from_path(@original_file_name, s3_service)
updated_schemes_csv = csv_from_path(@updated_file_name, s3_service) updated_schemes_csv = csv_from_path(@updated_file_name, s3_service)

2
app/services/bulk_upload/downloader.rb

@ -37,7 +37,7 @@ private
end end
def s3_storage_service def s3_storage_service
Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
end end
def local_disk_storage_service def local_disk_storage_service

2
lib/tasks/data_export.rake

@ -9,7 +9,7 @@ namespace :core do
desc "Export all data XMLs for import into Central Data System (CDS)" desc "Export all data XMLs for import into Central Data System (CDS)"
task :full_data_export_xml, %i[year] => :environment do |_task, args| task :full_data_export_xml, %i[year] => :environment do |_task, args|
collection_year = args[:year].present? ? args[:year].to_i : nil collection_year = args[:year].present? ? args[:year].to_i : nil
storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_PAAS_INSTANCE"]) storage_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["EXPORT_BUCKET"])
export_service = Exports::LettingsLogExportService.new(storage_service) export_service = Exports::LettingsLogExportService.new(storage_service)
export_service.export_xml_lettings_logs(full_update: true, collection_year:) export_service.export_xml_lettings_logs(full_update: true, collection_year:)

4
lib/tasks/import_address_from_csv.rake

@ -5,7 +5,7 @@ namespace :data_import do
raise "Usage: rake data_import:import_lettings_addresses_from_csv['csv_file_name']" if file_name.blank? raise "Usage: rake data_import:import_lettings_addresses_from_csv['csv_file_name']" if file_name.blank?
s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
file_io = s3_service.get_file_io(file_name) file_io = s3_service.get_file_io(file_name)
file_io.set_encoding_by_bom file_io.set_encoding_by_bom
addresses_csv = CSV.parse(file_io, headers: true) addresses_csv = CSV.parse(file_io, headers: true)
@ -69,7 +69,7 @@ namespace :data_import do
raise "Usage: rake data_import:import_sales_addresses_from_csv['csv_file_name']" if file_name.blank? raise "Usage: rake data_import:import_sales_addresses_from_csv['csv_file_name']" if file_name.blank?
s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["CSV_DOWNLOAD_PAAS_INSTANCE"]) s3_service = Storage::S3Service.new(Configuration::EnvConfigurationService.new, ENV["BULK_UPLOAD_BUCKET"])
file_io = s3_service.get_file_io(file_name) file_io = s3_service.get_file_io(file_name)
file_io.set_encoding_by_bom file_io.set_encoding_by_bom
addresses_csv = CSV.parse(file_io, headers: true) addresses_csv = CSV.parse(file_io, headers: true)

2
spec/lib/tasks/correct_address_from_csv_spec.rb

@ -15,7 +15,7 @@ RSpec.describe "data_import" do
allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service)
allow(ENV).to receive(:[]) allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("CSV_DOWNLOAD_PAAS_INSTANCE").and_return(instance_name) allow(ENV).to receive(:[]).with("BULK_UPLOAD_BUCKET").and_return(instance_name)
allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return("dummy") allow(ENV).to receive(:[]).with("VCAP_SERVICES").and_return("dummy")
WebMock.stub_request(:get, /api\.postcodes\.io/) WebMock.stub_request(:get, /api\.postcodes\.io/)

4
spec/lib/tasks/data_export_spec.rb

@ -2,7 +2,7 @@ require "rails_helper"
require "rake" require "rake"
describe "rake core:data_export", type: task do describe "rake core:data_export", type: task do
let(:export_instance) { "export_instance" } let(:export_bucket) { "export_bucket" }
let(:storage_service) { instance_double(Storage::S3Service) } let(:storage_service) { instance_double(Storage::S3Service) }
let(:export_service) { instance_double(Exports::LettingsLogExportService) } let(:export_service) { instance_double(Exports::LettingsLogExportService) }
@ -14,7 +14,7 @@ describe "rake core:data_export", type: task do
allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(Exports::LettingsLogExportService).to receive(:new).and_return(export_service) allow(Exports::LettingsLogExportService).to receive(:new).and_return(export_service)
allow(ENV).to receive(:[]) allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("EXPORT_PAAS_INSTANCE").and_return(export_instance) allow(ENV).to receive(:[]).with("EXPORT_BUCKET").and_return(export_bucket)
end end
context "when exporting lettings logs with no parameters" do context "when exporting lettings logs with no parameters" do

2
spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

@ -22,7 +22,7 @@ RSpec.describe "bulk_update" do
allow(Storage::S3Service).to receive(:new).and_return(storage_service) allow(Storage::S3Service).to receive(:new).and_return(storage_service)
allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) allow(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service)
allow(ENV).to receive(:[]) allow(ENV).to receive(:[])
allow(ENV).to receive(:[]).with("CSV_DOWNLOAD_PAAS_INSTANCE").and_return(instance_name) allow(ENV).to receive(:[]).with("BULK_UPLOAD_BUCKET").and_return(instance_name)
WebMock.stub_request(:get, /api\.postcodes\.io/) WebMock.stub_request(:get, /api\.postcodes\.io/)
.to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {}) .to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})

Loading…
Cancel
Save