Browse Source

log updates logs and don't mark them unesolved

pull/2144/head
Kat 2 years ago
parent
commit
7bc4aab6ec
  1. 10
      app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb
  2. 4
      spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

10
app/services/bulk_update_from_csv/update_schemes_from_csv_service.rb

@ -93,8 +93,14 @@ private
scheme["owning_organisation_id"] = organisation.id
Rails.logger.info("Updating scheme #{original_attributes['scheme_code']} with owning_organisation: #{organisation.name}")
editable_from_date = FormHandler.instance.earliest_open_for_editing_collection_start_date
LettingsLog.where(scheme_id: scheme.id).after_date(editable_from_date).update!(location: nil, scheme: nil, unresolved: true)
LettingsLog.where(scheme_id: scheme.id).where(startdate: nil).update!(location: nil, scheme: nil, unresolved: true)
editable_logs_with_startdate = LettingsLog.where(scheme_id: scheme.id).after_date(editable_from_date)
editable_logs_with_startdate.update!(location: nil, scheme: nil)
Rails.logger.info("Updated logs with startdate for scheme S#{scheme.id}. Log IDs: #{editable_logs_with_startdate.map(&:id).join(', ')}")
logs_without_start_date = LettingsLog.where(scheme_id: scheme.id).where(startdate: nil)
logs_without_start_date.update!(location: nil, scheme: nil)
Rails.logger.info("Updated logs without startdate for scheme S#{scheme.id}. Log IDs: #{logs_without_start_date.map(&:id).join(', ')}")
end
else
Rails.logger.info("Cannot update scheme #{original_attributes['scheme_code']} with owning_organisation: #{value}. Organisation with name #{value} is not in the database or is not related to current organisation")

4
spec/lib/tasks/update_schemes_and_locations_from_csv_spec.rb

@ -111,7 +111,6 @@ RSpec.describe "bulk_update" do
lettings_log.reload
expect(lettings_log.scheme).to be_nil
expect(lettings_log.location).to be_nil
expect(lettings_log.unresolved).to eq(true)
end
it "does not update the scheme if it hasn't changed" do
@ -174,7 +173,6 @@ RSpec.describe "bulk_update" do
lettings_log.reload
expect(lettings_log.scheme).not_to be_nil
expect(lettings_log.location).not_to be_nil
expect(lettings_log.unresolved).to be_falsey
end
it "only re-exports the logs for the schemes that have been updated" do
@ -206,6 +204,8 @@ RSpec.describe "bulk_update" do
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with service_name: Updated test name")
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with sensitive: No")
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with scheme_type: Direct Access Hostel")
expect(Rails.logger).to receive(:info).with("Updated logs with startdate for scheme S#{schemes[0].id}. Log IDs: ")
expect(Rails.logger).to receive(:info).with("Updated logs without startdate for scheme S#{schemes[0].id}. Log IDs: #{lettings_log.id}, #{lettings_log_4.id}, #{lettings_log_5.id}")
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with arrangement_type: Another registered stock owner")
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with primary_client_group: People with drug problems")
expect(Rails.logger).to receive(:info).with("Updating scheme S#{schemes[0].id} with has_other_client_group: No")

Loading…
Cancel
Save