diff --git a/app/jobs/create_addresses_csv_job.rb b/app/jobs/create_addresses_csv_job.rb index ef83ee746..3a6352f29 100644 --- a/app/jobs/create_addresses_csv_job.rb +++ b/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" 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) Rails.logger.info("Created addresses file: #{filename}") diff --git a/app/jobs/data_export_xml_job.rb b/app/jobs/data_export_xml_job.rb index 60633d21a..8b825f6df 100644 --- a/app/jobs/data_export_xml_job.rb +++ b/app/jobs/data_export_xml_job.rb @@ -2,7 +2,7 @@ class DataExportXmlJob < ApplicationJob queue_as :default 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.export_xml_lettings_logs(full_update:) diff --git a/app/jobs/email_csv_job.rb b/app/jobs/email_csv_job.rb index 7658cf755..3166bb729 100644 --- a/app/jobs/email_csv_job.rb +++ b/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" - 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) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/jobs/email_missing_addresses_csv_job.rb b/app/jobs/email_missing_addresses_csv_job.rb index d8b756b20..4f2d1a3fb 100644 --- a/app/jobs/email_missing_addresses_csv_job.rb +++ b/app/jobs/email_missing_addresses_csv_job.rb @@ -18,7 +18,7 @@ class EmailMissingAddressesCsvJob < ApplicationJob email_method = :send_missing_sales_addresses_csv_download_mail 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) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/jobs/scheme_email_csv_job.rb b/app/jobs/scheme_email_csv_job.rb index 9c3060cb9..44d016a90 100644 --- a/app/jobs/scheme_email_csv_job.rb +++ b/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" 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) url = storage_service.get_presigned_url(filename, EXPIRATION_TIME) diff --git a/app/models/forms/bulk_upload_lettings/upload_your_file.rb b/app/models/forms/bulk_upload_lettings/upload_your_file.rb index 319bfc636..9ccec7622 100644 --- a/app/models/forms/bulk_upload_lettings/upload_your_file.rb +++ b/app/models/forms/bulk_upload_lettings/upload_your_file.rb @@ -56,7 +56,7 @@ module Forms def storage_service @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 Storage::LocalDiskService.new end diff --git a/app/models/forms/bulk_upload_sales/upload_your_file.rb b/app/models/forms/bulk_upload_sales/upload_your_file.rb index 37199ab92..de650c831 100644 --- a/app/models/forms/bulk_upload_sales/upload_your_file.rb +++ b/app/models/forms/bulk_upload_sales/upload_your_file.rb @@ -49,7 +49,7 @@ module Forms def storage_service @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 Storage::LocalDiskService.new end diff --git a/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb b/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb index 4a2577fc3..56a8da6d1 100644 --- a/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb +++ b/app/services/bulk_update_from_csv/update_locations_from_csv_service.rb @@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateLocationsFromCsvService end 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) updated_locations_csv = csv_from_path(@updated_file_name, s3_service) diff --git a/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb b/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb index bb4a0c261..ff9a42494 100644 --- a/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb +++ b/app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb @@ -5,7 +5,7 @@ class BulkUpdateFromCsv::UpdateSchemesFromCsvService end 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) updated_schemes_csv = csv_from_path(@updated_file_name, s3_service) diff --git a/app/services/bulk_upload/downloader.rb b/app/services/bulk_upload/downloader.rb index 452aed689..a7dc9aad0 100644 --- a/app/services/bulk_upload/downloader.rb +++ b/app/services/bulk_upload/downloader.rb @@ -37,7 +37,7 @@ private end 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 def local_disk_storage_service diff --git a/lib/tasks/data_export.rake b/lib/tasks/data_export.rake index e62d6ee65..719462cb4 100644 --- a/lib/tasks/data_export.rake +++ b/lib/tasks/data_export.rake @@ -9,7 +9,7 @@ namespace :core do desc "Export all data XMLs for import into Central Data System (CDS)" task :full_data_export_xml, %i[year] => :environment do |_task, args| 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.export_xml_lettings_logs(full_update: true, collection_year:) diff --git a/lib/tasks/import_address_from_csv.rake b/lib/tasks/import_address_from_csv.rake index e6c44872b..6b6d6e1ba 100644 --- a/lib/tasks/import_address_from_csv.rake +++ b/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? - 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.set_encoding_by_bom 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? - 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.set_encoding_by_bom addresses_csv = CSV.parse(file_io, headers: true) diff --git a/spec/lib/tasks/correct_address_from_csv_spec.rb b/spec/lib/tasks/correct_address_from_csv_spec.rb index 26b048e5f..22b504eaf 100644 --- a/spec/lib/tasks/correct_address_from_csv_spec.rb +++ b/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(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) 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") WebMock.stub_request(:get, /api\.postcodes\.io/) diff --git a/spec/lib/tasks/data_export_spec.rb b/spec/lib/tasks/data_export_spec.rb index 8e98309a8..afb99f872 100644 --- a/spec/lib/tasks/data_export_spec.rb +++ b/spec/lib/tasks/data_export_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" require "rake" 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(: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(Exports::LettingsLogExportService).to receive(:new).and_return(export_service) 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 context "when exporting lettings logs with no parameters" do diff --git a/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb b/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb index e3bdc6831..ba87cc15a 100644 --- a/spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb +++ b/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(Configuration::EnvConfigurationService).to receive(:new).and_return(env_config_service) 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/) .to_return(status: 200, body: "{\"status\":404,\"error\":\"Postcode not found\"}", headers: {})