Browse Source

Ensure that logs exported with datetimes are local times (#965)

Follows on from https://github.com/communitiesuk/submit-social-housing-lettings-and-sales-data/pull/960
pull/972/head v0.2.18
James Rose 2 years ago committed by GitHub
parent
commit
20159bba13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      app/services/exports/lettings_log_export_service.rb
  2. 2
      spec/factories/lettings_log.rb
  3. 2
      spec/fixtures/exports/general_needs_log.csv
  4. 10
      spec/fixtures/exports/general_needs_log.xml
  5. 10
      spec/fixtures/exports/supported_housing_logs.xml

14
app/services/exports/lettings_log_export_service.rb

@ -176,16 +176,12 @@ module Exports
attribute_hash["manhcnum"] = lettings_log.managing_organisation.housing_registration_no
end
# Mapping which would require a change in our data model
attribute_hash["createddate"] = attribute_hash["created_at"]
attribute_hash["uploaddate"] = attribute_hash["updated_at"]
# Covert date times to ISO 8601
attribute_hash["createddate"] = attribute_hash["createddate"]&.iso8601
attribute_hash["uploaddate"] = attribute_hash["uploaddate"]&.iso8601
attribute_hash["mrcdate"] = attribute_hash["mrcdate"]&.iso8601
attribute_hash["startdate"] = attribute_hash["startdate"]&.iso8601
attribute_hash["voiddate"] = attribute_hash["voiddate"]&.iso8601
attribute_hash["createddate"] = lettings_log.created_at&.iso8601
attribute_hash["uploaddate"] = lettings_log.updated_at&.iso8601
attribute_hash["mrcdate"] = lettings_log.mrcdate&.iso8601
attribute_hash["startdate"] = lettings_log.startdate&.iso8601
attribute_hash["voiddate"] = lettings_log.voiddate&.iso8601
attribute_hash["cbl"] = 2 if attribute_hash["cbl"]&.zero?
attribute_hash["cap"] = 2 if attribute_hash["cap"]&.zero?

2
spec/factories/lettings_log.rb

@ -132,7 +132,7 @@ FactoryBot.define do
hbrentshortfall { 1 }
tshortfall { 12 }
property_relet { 0 }
mrcdate { Time.utc(2020, 5, 0o5, 10, 36, 49) }
mrcdate { Time.zone.local(2020, 5, 5, 10, 36, 49) }
incref { 0 }
startdate { Time.utc(2022, 2, 2, 10, 36, 49) }
armedforces { 1 }

2
spec/fixtures/exports/general_needs_log.csv vendored

@ -1,2 +1,2 @@
status,tenancycode,age1,sex1,ethnic,national,prevten,ecstat1,hhmemb,age2,sex2,ecstat2,age3,sex3,ecstat3,age4,sex4,ecstat4,age5,sex5,ecstat5,age6,sex6,ecstat6,age7,sex7,ecstat7,age8,sex8,ecstat8,homeless,underoccupation_benefitcap,leftreg,reservist,illness,preg_occ,startertenancy,tenancylength,tenancy,ppostcode_full,rsnvac,unittype_gn,beds,offered,wchair,earnings,incfreq,benefits,period,layear,waityear,postcode_full,reasonpref,cbl,chr,cap,reasonother,housingneeds_a,housingneeds_b,housingneeds_c,housingneeds_f,housingneeds_g,housingneeds_h,illness_type_1,illness_type_2,illness_type_3,illness_type_4,illness_type_8,illness_type_5,illness_type_6,illness_type_7,illness_type_9,illness_type_10,rp_homeless,rp_insan_unsat,rp_medwel,rp_hardship,rp_dontknow,tenancyother,irproduct_other,reason,propcode,la,prevloc,hb,hbrentshortfall,mrcdate,incref,startdate,armedforces,unitletas,builtype,voiddate,renttype,needstype,lettype,totchild,totelder,totadult,nocharge,referral,brent,scharge,pscharge,supcharg,tcharge,tshortfall,chcharge,ppcodenk,has_benefits,renewal,wrent,wscharge,wpschrge,wsupchrg,wtcharge,wtshortfall,refused,housingneeds,wchchrg,newprop,relat2,relat3,relat4,relat5,relat6,relat7,relat8,lar,irproduct,joint,sheltered,hhtype,new_old,vacdays,form,owningorgid,owningorgname,hcnum,maningorgid,maningorgname,manhcnum,createddate,uploaddate
2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,0,1,1,1,2,1,5,1,SE2 6RT,6,7,3,2,1,68,1,1,2,2,1,NW1 5TY,1,1,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49Z,0,2022-02-02T10:36:49Z,1,2,1,2019-11-03T00:00:00Z,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08T16:52:15Z,2022-02-08T16:52:15Z
2,BZ737,35,F,2,4,6,0,2,32,M,6,,,,,,,,,,,,,,,,,,,1,0,1,1,1,2,1,5,1,SE2 6RT,6,7,3,2,1,68,1,1,2,2,1,NW1 5TY,1,1,1,2,,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,,,4,123,E09000003,E07000105,6,1,2020-05-05T10:36:49+01:00,0,2022-02-02T10:36:49+00:00,1,2,1,2019-11-03T00:00:00+00:00,2,1,7,0,0,2,0,2,200.0,50.0,40.0,35.0,325.0,12.0,,1,1,0,100.0,25.0,20.0,17.5,162.5,6.0,0,1,,2,P,,,,,,,,,,,4,2,638,{id},{owning_org_id},DLUHC,1234,{managing_org_id},DLUHC,1234,2022-02-08T16:52:15+00:00,2022-02-08T16:52:15+00:00

1 status tenancycode age1 sex1 ethnic national prevten ecstat1 hhmemb age2 sex2 ecstat2 age3 sex3 ecstat3 age4 sex4 ecstat4 age5 sex5 ecstat5 age6 sex6 ecstat6 age7 sex7 ecstat7 age8 sex8 ecstat8 homeless underoccupation_benefitcap leftreg reservist illness preg_occ startertenancy tenancylength tenancy ppostcode_full rsnvac unittype_gn beds offered wchair earnings incfreq benefits period layear waityear postcode_full reasonpref cbl chr cap reasonother housingneeds_a housingneeds_b housingneeds_c housingneeds_f housingneeds_g housingneeds_h illness_type_1 illness_type_2 illness_type_3 illness_type_4 illness_type_8 illness_type_5 illness_type_6 illness_type_7 illness_type_9 illness_type_10 rp_homeless rp_insan_unsat rp_medwel rp_hardship rp_dontknow tenancyother irproduct_other reason propcode la prevloc hb hbrentshortfall mrcdate incref startdate armedforces unitletas builtype voiddate renttype needstype lettype totchild totelder totadult nocharge referral brent scharge pscharge supcharg tcharge tshortfall chcharge ppcodenk has_benefits renewal wrent wscharge wpschrge wsupchrg wtcharge wtshortfall refused housingneeds wchchrg newprop relat2 relat3 relat4 relat5 relat6 relat7 relat8 lar irproduct joint sheltered hhtype new_old vacdays form owningorgid owningorgname hcnum maningorgid maningorgname manhcnum createddate uploaddate
2 2 BZ737 35 F 2 4 6 0 2 32 M 6 1 0 1 1 1 2 1 5 1 SE2 6RT 6 7 3 2 1 68 1 1 2 2 1 NW1 5TY 1 1 1 2 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 4 123 E09000003 E07000105 6 1 2020-05-05T10:36:49Z 2020-05-05T10:36:49+01:00 0 2022-02-02T10:36:49Z 2022-02-02T10:36:49+00:00 1 2 1 2019-11-03T00:00:00Z 2019-11-03T00:00:00+00:00 2 1 7 0 0 2 0 2 200.0 50.0 40.0 35.0 325.0 12.0 1 1 0 100.0 25.0 20.0 17.5 162.5 6.0 0 1 2 P 4 2 638 {id} {owning_org_id} DLUHC 1234 {managing_org_id} DLUHC 1234 2022-02-08T16:52:15Z 2022-02-08T16:52:15+00:00 2022-02-08T16:52:15Z 2022-02-08T16:52:15+00:00

10
spec/fixtures/exports/general_needs_log.xml vendored

@ -87,13 +87,13 @@
<prevloc>E07000105</prevloc>
<hb>6</hb>
<hbrentshortfall>1</hbrentshortfall>
<mrcdate>2020-05-05T10:36:49Z</mrcdate>
<mrcdate>2020-05-05T10:36:49+01:00</mrcdate>
<incref>0</incref>
<startdate>2022-02-02T10:36:49Z</startdate>
<startdate>2022-02-02T10:36:49+00:00</startdate>
<armedforces>1</armedforces>
<unitletas>2</unitletas>
<builtype>1</builtype>
<voiddate>2019-11-03T00:00:00Z</voiddate>
<voiddate>2019-11-03T00:00:00+00:00</voiddate>
<renttype>2</renttype>
<needstype>1</needstype>
<lettype>7</lettype>
@ -142,8 +142,8 @@
<maningorgid>{managing_org_id}</maningorgid>
<maningorgname>DLUHC</maningorgname>
<manhcnum>1234</manhcnum>
<createddate>2022-02-08T16:52:15Z</createddate>
<uploaddate>2022-02-08T16:52:15Z</uploaddate>
<createddate>2022-02-08T16:52:15+00:00</createddate>
<uploaddate>2022-02-08T16:52:15+00:00</uploaddate>
<providertype>1</providertype>
</form>
</forms>

10
spec/fixtures/exports/supported_housing_logs.xml vendored

@ -86,13 +86,13 @@
<prevloc>E07000105</prevloc>
<hb>6</hb>
<hbrentshortfall>1</hbrentshortfall>
<mrcdate>2020-05-05T10:36:49Z</mrcdate>
<mrcdate>2020-05-05T10:36:49+01:00</mrcdate>
<incref>0</incref>
<startdate>2022-02-02T10:36:49Z</startdate>
<startdate>2022-02-02T10:36:49+00:00</startdate>
<armedforces>1</armedforces>
<unitletas/>
<builtype/>
<voiddate>2019-11-03T00:00:00Z</voiddate>
<voiddate>2019-11-03T00:00:00+00:00</voiddate>
<renttype>2</renttype>
<needstype>2</needstype>
<lettype>8</lettype>
@ -141,8 +141,8 @@
<maningorgid>{managing_org_id}</maningorgid>
<maningorgname>DLUHC</maningorgname>
<manhcnum>1234</manhcnum>
<createddate>2022-02-08T16:52:15Z</createddate>
<uploaddate>2022-02-08T16:52:15Z</uploaddate>
<createddate>2022-02-08T16:52:15+00:00</createddate>
<uploaddate>2022-02-08T16:52:15+00:00</uploaddate>
<unittype_sh>7</unittype_sh>
<confidential>1</confidential>
<cligrp1>G</cligrp1>

Loading…
Cancel
Save