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"
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}")

2
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:)

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"
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)

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
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)

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"
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)

2
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

2
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

2
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)

2
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)

2
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

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)"
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:)

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?
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)

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(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/)

4
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

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(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: {})

Loading…
Cancel
Save