Browse Source

CLDC-1903 Infer first time property let question (#1300)

pull/1309/head
Jack 2 years ago committed by GitHub
parent
commit
65bde2b7f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/models/derived_variables/lettings_log_variables.rb
  2. 18
      lib/tasks/data_export.rake
  3. 9
      spec/models/lettings_log_spec.rb

3
app/models/derived_variables/lettings_log_variables.rb

@ -46,6 +46,8 @@ module DerivedVariables::LettingsLogVariables
self.referral = 1 self.referral = 1
self.waityear = 2 self.waityear = 2
self.offered = 0 self.offered = 0
self.voiddate = startdate
self.first_time_property_let_as_social_housing = 0
if is_general_needs? if is_general_needs?
# fixed term # fixed term
self.prevten = 32 if managing_organisation&.provider_type == "PRP" self.prevten = 32 if managing_organisation&.provider_type == "PRP"
@ -61,7 +63,6 @@ module DerivedVariables::LettingsLogVariables
if is_supported_housing? && location if is_supported_housing? && location
self.wchair = location.mobility_type_before_type_cast == "W" ? 1 : 2 self.wchair = location.mobility_type_before_type_cast == "W" ? 1 : 2
end end
self.voiddate = startdate if is_renewal?
self.vacdays = property_vacant_days self.vacdays = property_vacant_days
set_housingneeds_fields if housingneeds? set_housingneeds_fields if housingneeds?

18
lib/tasks/data_export.rake

@ -11,21 +11,3 @@ namespace :core do
DataExportXmlJob.perform_later(full_update:) DataExportXmlJob.perform_later(full_update:)
end end
end end
namespace :illness_type_0 do
desc "Export log data where illness_type_0 == 1"
task export: :environment do |_task|
logs = LettingsLog.where(illness_type_0: 1, status: "completed").includes(created_by: :organisation)
puts "log_id,created_by_id,organisation_id,organisation_name,startdate"
logs.each do |log|
puts [
log.id,
log.created_by_id,
log.created_by.organisation.id,
log.created_by.organisation.name,
log.startdate&.strftime("%d/%m/%Y"),
].join(",")
end
end
end

9
spec/models/lettings_log_spec.rb

@ -1459,6 +1459,15 @@ RSpec.describe LettingsLog do
expect(record_from_db["vacdays"]).to eq(0) expect(record_from_db["vacdays"]).to eq(0)
expect(lettings_log["vacdays"]).to eq(0) expect(lettings_log["vacdays"]).to eq(0)
end end
it "correctly derives and saves first_time_property_let_as_social_housing" do
record_from_db = ActiveRecord::Base.connection.execute(
"select first_time_property_let_as_social_housing" \
" from lettings_logs where id=#{lettings_log.id}",
).to_a[0]
expect(record_from_db["first_time_property_let_as_social_housing"]).to eq(0)
expect(lettings_log["first_time_property_let_as_social_housing"]).to eq(0)
end
end end
context "when answering the household characteristics questions" do context "when answering the household characteristics questions" do

Loading…
Cancel
Save