Browse Source

feat: respond to PR comments

pull/1225/head
natdeanlewissoftwire 2 years ago
parent
commit
99c87f1eb5
  1. 2
      app/models/la_purchase_price_range.rb
  2. 2
      app/models/la_sale_range.rb
  3. 4
      app/models/sales_log.rb
  4. 10
      app/models/validations/sales/soft_validations.rb
  5. 4
      app/services/imports/sale_ranges_service.rb
  6. 0
      config/sale_range_data/2022.csv
  7. 6
      db/migrate/20230124111328_create_la_sale_ranges.rb
  8. 20
      db/schema.rb
  9. 4
      db/seeds.rb
  10. 14
      lib/tasks/purchase_price_ranges.rake
  11. 14
      lib/tasks/sale_ranges.rake
  12. 0
      spec/fixtures/files/sale_ranges.csv
  13. 47
      spec/lib/tasks/purchase_price_range_import_spec.rb
  14. 47
      spec/lib/tasks/sale_range_import_spec.rb
  15. 2
      spec/models/validations/sales/soft_validations_spec.rb

2
app/models/la_purchase_price_range.rb

@ -1,2 +0,0 @@
class LaPurchasePriceRange < ApplicationRecord
end

2
app/models/la_sale_range.rb

@ -0,0 +1,2 @@
class LaSaleRange < ApplicationRecord
end

4
app/models/sales_log.rb

@ -204,10 +204,10 @@ class SalesLog < Log
end
def purchase_price_soft_min
LaPurchasePriceRange.find_by(start_year: collection_start_year, la:, bedrooms: beds).soft_min
LaSaleRange.find_by(start_year: collection_start_year, la:, bedrooms: beds).soft_min
end
def purchase_price_soft_max
LaPurchasePriceRange.find_by(start_year: collection_start_year, la:, bedrooms: beds).soft_max
LaSaleRange.find_by(start_year: collection_start_year, la:, bedrooms: beds).soft_max
end
end

10
app/models/validations/sales/soft_validations.rb

@ -46,20 +46,20 @@ module Validations::Sales::SoftValidations
def purchase_price_out_of_soft_range?
return unless value && beds && la
purchase_price_range.present? && !value.between?(purchase_price_range.soft_min, purchase_price_range.soft_max)
sale_range.present? && !value.between?(sale_range.soft_min, sale_range.soft_max)
end
def purchase_price_min_or_max_text
value < purchase_price_range.soft_min ? "minimum" : "maximum"
value < sale_range.soft_min ? "minimum" : "maximum"
end
def purchase_price_soft_min_or_soft_max
value < purchase_price_range.soft_min ? purchase_price_range.soft_min : purchase_price_range.soft_max
value < sale_range.soft_min ? sale_range.soft_min : sale_range.soft_max
end
private
def purchase_price_range
LaPurchasePriceRange.find_by(start_year: collection_start_year, la:, bedrooms: beds)
def sale_range
LaSaleRange.find_by(start_year: collection_start_year, la:, bedrooms: beds)
end
end

4
app/services/imports/purchase_price_ranges_service.rb → app/services/imports/sale_ranges_service.rb

@ -1,7 +1,7 @@
require "csv"
module Imports
class PurchasePriceRangesService
class SaleRangesService
attr_reader :start_year, :path, :count
def initialize(start_year:, path:)
@ -12,7 +12,7 @@ module Imports
def call
CSV.foreach(path, headers: true) do |row|
LaPurchasePriceRange.upsert(
LaSaleRange.upsert(
{ start_year:,
la: row["la"],
bedrooms: row["bedrooms"],

0
config/purchase_price_range_data/2022.csv → config/sale_range_data/2022.csv

1 la_name la bedrooms soft_min soft_max
2 Adur E07000223 1 105000 369000
3 Adur E07000223 2 177000 384000
4 Adur E07000223 3 246000 539000
5 Adur E07000223 4 310000 860000
6 Allerdale E07000026 1 49000 232000
7 Allerdale E07000026 2 54000 232000
8 Allerdale E07000026 3 69000 270000
9 Allerdale E07000026 4 105000 463000
10 Amber Valley E07000032 1 74000 230000
11 Amber Valley E07000032 2 74000 230000
12 Amber Valley E07000032 3 90000 289000
13 Amber Valley E07000032 4 168000 631000
14 Arun E07000224 1 82000 397000
15 Arun E07000224 2 138000 397000
16 Arun E07000224 3 193000 458000
17 Arun E07000224 4 273000 822000
18 Ashfield E07000170 1 58000 189000
19 Ashfield E07000170 2 64000 189000
20 Ashfield E07000170 3 75000 229000
21 Ashfield E07000170 4 140000 401000
22 Ashford E07000105 1 68000 345000
23 Ashford E07000105 2 83000 345000
24 Ashford E07000105 3 184000 460000
25 Ashford E07000105 4 271000 917000
26 Aylesbury Vale E07000004 1 108000 370000
27 Aylesbury Vale E07000004 2 112000 370000
28 Aylesbury Vale E07000004 3 228000 501000
29 Aylesbury Vale E07000004 4 341000 940000
30 Babergh E07000200 1 74000 340000
31 Babergh E07000200 2 109000 340000
32 Babergh E07000200 3 175000 459000
33 Babergh E07000200 4 273000 971000
34 Barking and Dagenham E09000002 1 72000 344000
35 Barking and Dagenham E09000002 2 83000 352000
36 Barking and Dagenham E09000002 3 201000 450000
37 Barking and Dagenham E09000002 4 301000 577000
38 Barnet E09000003 1 114000 523000
39 Barnet E09000003 2 213000 621000
40 Barnet E09000003 3 373000 947000
41 Barnet E09000003 4 591000 2239000
42 Barnsley E08000016 1 53000 176000
43 Barnsley E08000016 2 53000 176000
44 Barnsley E08000016 3 67000 220000
45 Barnsley E08000016 4 124000 432000
46 Barrow-in-Furness E07000027 1 50000 157000
47 Barrow-in-Furness E07000027 2 52000 157000
48 Barrow-in-Furness E07000027 3 74000 256000
49 Barrow-in-Furness E07000027 4 100000 408000
50 Basildon E07000066 1 75000 375000
51 Basildon E07000066 2 105000 375000
52 Basildon E07000066 3 217000 463000
53 Basildon E07000066 4 299000 898000
54 Basingstoke and Deane E07000084 1 77000 347000
55 Basingstoke and Deane E07000084 2 108000 347000
56 Basingstoke and Deane E07000084 3 212000 464000
57 Basingstoke and Deane E07000084 4 309000 924000
58 Bassetlaw E07000171 1 65000 231000
59 Bassetlaw E07000171 2 65000 231000
60 Bassetlaw E07000171 3 77000 271000
61 Bassetlaw E07000171 4 139000 467000
62 Bath and North East Somerset E06000022 1 91000 452000
63 Bath and North East Somerset E06000022 2 112000 452000
64 Bath and North East Somerset E06000022 3 182000 584000
65 Bath and North East Somerset E06000022 4 280000 1217000
66 Bedford E06000055 1 76000 286000
67 Bedford E06000055 2 88000 286000
68 Bedford E06000055 3 158000 372000
69 Bedford E06000055 4 290000 788000
70 Bexley E09000004 1 102000 404000
71 Bexley E09000004 2 151000 404000
72 Bexley E09000004 3 280000 517000
73 Bexley E09000004 4 363000 853000
74 Birmingham E08000025 1 57000 271000
75 Birmingham E08000025 2 76000 271000
76 Birmingham E08000025 3 96000 336000
77 Birmingham E08000025 4 142000 757000
78 Blaby E07000129 1 81000 264000
79 Blaby E07000129 2 81000 264000
80 Blaby E07000129 3 136000 306000
81 Blaby E07000129 4 202000 539000
82 Blackburn with Darwen E06000008 1 48000 172000
83 Blackburn with Darwen E06000008 2 52000 172000
84 Blackburn with Darwen E06000008 3 66000 229000
85 Blackburn with Darwen E06000008 4 110000 458000
86 Blackpool E06000009 1 29000 158000
87 Blackpool E06000009 2 58000 158000
88 Blackpool E06000009 3 72000 196000
89 Blackpool E06000009 4 84000 316000
90 Bolsover E07000033 1 56000 163000
91 Bolsover E07000033 2 59000 163000
92 Bolsover E07000033 3 60000 212000
93 Bolsover E07000033 4 126000 432000
94 Bolton E08000001 1 56000 193000
95 Bolton E08000001 2 59000 193000
96 Bolton E08000001 3 73000 258000
97 Bolton E08000001 4 125000 557000
98 Boston E07000136 1 39000 190000
99 Boston E07000136 2 39000 190000
100 Boston E07000136 3 73000 233000
101 Boston E07000136 4 152000 387000
102 Bournemouth E06000028 1 97000 318000
103 Bournemouth E06000028 2 135000 318000
104 Bournemouth E06000028 3 189000 450000
105 Bournemouth E06000028 4 272000 783000
106 Bournemouth, Christchurch and Poole E06000058 1 105000 385000
107 Bournemouth, Christchurch and Poole E06000058 2 153000 386000
108 Bournemouth, Christchurch and Poole E06000058 3 227000 526000
109 Bournemouth, Christchurch and Poole E06000058 4 286000 1117000
110 Bracknell Forest E06000036 1 79000 403000
111 Bracknell Forest E06000036 2 124000 403000
112 Bracknell Forest E06000036 3 269000 525000
113 Bracknell Forest E06000036 4 333000 950000
114 Bradford E08000032 1 47000 218000
115 Bradford E08000032 2 57000 218000
116 Bradford E08000032 3 71000 280000
117 Bradford E08000032 4 92000 606000
118 Braintree E07000067 1 101000 333000
119 Braintree E07000067 2 117000 333000
120 Braintree E07000067 3 215000 433000
121 Braintree E07000067 4 292000 922000
122 Breckland E07000143 1 80000 253000
123 Breckland E07000143 2 98000 253000
124 Breckland E07000143 3 135000 335000
125 Breckland E07000143 4 210000 645000
126 Brent E09000005 1 94000 548000
127 Brent E09000005 2 128000 705000
128 Brent E09000005 3 344000 1122000
129 Brent E09000005 4 499000 2304000
130 Brentwood E07000068 1 117000 430000
131 Brentwood E07000068 2 203000 532000
132 Brentwood E07000068 3 319000 744000
133 Brentwood E07000068 4 418000 1589000
134 Brighton and Hove E06000043 1 146000 444000
135 Brighton and Hove E06000043 2 220000 483000
136 Brighton and Hove E06000043 3 280000 668000
137 Brighton and Hove E06000043 4 366000 1264000
138 Bristol, City of E06000023 1 107000 313000
139 Bristol, City of E06000023 2 132000 420000
140 Bristol, City of E06000023 3 175000 520000
141 Bristol, City of E06000023 4 244000 1079000
142 Broadland E07000144 1 97000 270000
143 Broadland E07000144 2 102000 270000
144 Broadland E07000144 3 177000 353000
145 Broadland E07000144 4 239000 638000
146 Bromley E09000006 1 172000 492000
147 Bromley E09000006 2 238000 553000
148 Bromley E09000006 3 312000 728000
149 Bromley E09000006 4 442000 1411000
150 Bromsgrove E07000234 1 85000 354000
151 Bromsgrove E07000234 2 89000 354000
152 Bromsgrove E07000234 3 139000 417000
153 Bromsgrove E07000234 4 254000 829000
154 Broxbourne E07000095 1 152000 406000
155 Broxbourne E07000095 2 200000 406000
156 Broxbourne E07000095 3 294000 541000
157 Broxbourne E07000095 4 388000 1152000
158 Broxtowe E07000172 1 69000 217000
159 Broxtowe E07000172 2 79000 217000
160 Broxtowe E07000172 3 109000 292000
161 Broxtowe E07000172 4 169000 541000
162 Buckinghamshire E06000060 1 130000 588000
163 Buckinghamshire E06000060 2 139000 588000
164 Buckinghamshire E06000060 3 239000 714000
165 Buckinghamshire E06000060 4 389000 1703000
166 Burnley E07000117 1 42000 160000
167 Burnley E07000117 2 44000 160000
168 Burnley E07000117 3 60000 215000
169 Burnley E07000117 4 109000 366000
170 Bury E08000002 1 57000 236000
171 Bury E08000002 2 69000 236000
172 Bury E08000002 3 95000 295000
173 Bury E08000002 4 161000 580000
174 Calderdale E08000033 1 52000 207000
175 Calderdale E08000033 2 59000 207000
176 Calderdale E08000033 3 73000 291000
177 Calderdale E08000033 4 120000 561000
178 Cambridge E07000008 1 121000 534000
179 Cambridge E07000008 2 139000 538000
180 Cambridge E07000008 3 268000 685000
181 Cambridge E07000008 4 418000 1572000
182 Camden E09000007 1 243000 746000
183 Camden E09000007 2 382000 1311000
184 Camden E09000007 3 497000 2233000
185 Camden E09000007 4 915000 5132000
186 Cannock Chase E07000192 1 53000 190000
187 Cannock Chase E07000192 2 79000 190000
188 Cannock Chase E07000192 3 105000 252000
189 Cannock Chase E07000192 4 168000 402000
190 Canterbury E07000106 1 70000 362000
191 Canterbury E07000106 2 126000 362000
192 Canterbury E07000106 3 189000 477000
193 Canterbury E07000106 4 288000 870000
194 Carlisle E07000028 1 48000 180000
195 Carlisle E07000028 2 63000 180000
196 Carlisle E07000028 3 75000 248000
197 Carlisle E07000028 4 128000 418000
198 Castle Point E07000069 1 132000 368000
199 Castle Point E07000069 2 177000 368000
200 Castle Point E07000069 3 223000 432000
201 Castle Point E07000069 4 299000 779000
202 Central Bedfordshire E06000056 1 88000 329000
203 Central Bedfordshire E06000056 2 100000 329000
204 Central Bedfordshire E06000056 3 193000 433000
205 Central Bedfordshire E06000056 4 312000 784000
206 Charnwood E07000130 1 72000 250000
207 Charnwood E07000130 2 72000 250000
208 Charnwood E07000130 3 116000 309000
209 Charnwood E07000130 4 206000 597000
210 Chelmsford E07000070 1 75000 405000
211 Chelmsford E07000070 2 106000 405000
212 Chelmsford E07000070 3 261000 548000
213 Chelmsford E07000070 4 359000 979000
214 Cheltenham E07000078 1 85000 375000
215 Cheltenham E07000078 2 126000 375000
216 Cheltenham E07000078 3 168000 493000
217 Cheltenham E07000078 4 251000 979000
218 Cherwell E07000177 1 90000 345000
219 Cherwell E07000177 2 90000 345000
220 Cherwell E07000177 3 182000 445000
221 Cherwell E07000177 4 285000 819000
222 Cheshire East E06000049 1 64000 329000
223 Cheshire East E06000049 2 71000 329000
224 Cheshire East E06000049 3 98000 420000
225 Cheshire East E06000049 4 207000 885000
226 Cheshire West and Chester E06000050 1 59000 275000
227 Cheshire West and Chester E06000050 2 67000 275000
228 Cheshire West and Chester E06000050 3 89000 341000
229 Cheshire West and Chester E06000050 4 176000 716000
230 Chesterfield E07000034 1 54000 188000
231 Chesterfield E07000034 2 70000 188000
232 Chesterfield E07000034 3 81000 264000
233 Chesterfield E07000034 4 142000 480000
234 Chichester E07000225 1 79000 475000
235 Chichester E07000225 2 89000 475000
236 Chichester E07000225 3 221000 626000
237 Chichester E07000225 4 333000 1721000
238 Chiltern E07000005 1 170000 646000
239 Chiltern E07000005 2 227000 646000
240 Chiltern E07000005 3 333000 821000
241 Chiltern E07000005 4 461000 1850000
242 Chorley E07000118 1 54000 231000
243 Chorley E07000118 2 71000 231000
244 Chorley E07000118 3 87000 301000
245 Chorley E07000118 4 166000 550000
246 Christchurch E07000048 1 115000 425000
247 Christchurch E07000048 2 149000 425000
248 Christchurch E07000048 3 225000 510000
249 Christchurch E07000048 4 321000 814000
250 City of London E09000001 1 418000 917000
251 City of London E09000001 2 600000 2303000
252 City of London E09000001 3 1576000 4833000
253 City of London E09000001 4 1707000 2116000
254 Colchester E07000071 1 88000 307000
255 Colchester E07000071 2 130000 307000
256 Colchester E07000071 3 202000 400000
257 Colchester E07000071 4 289000 773000
258 Copeland E07000029 1 48000 182000
259 Copeland E07000029 2 53000 182000
260 Copeland E07000029 3 63000 238000
261 Copeland E07000029 4 102000 395000
262 Corby E07000150 1 63000 215000
263 Corby E07000150 2 70000 215000
264 Corby E07000150 3 108000 255000
265 Corby E07000150 4 166000 433000
266 Cornwall E06000052 1 74000 314000
267 Cornwall E06000052 2 75000 314000
268 Cornwall E06000052 3 116000 399000
269 Cornwall E06000052 4 186000 692000
270 Cotswold E07000079 1 54000 480000
271 Cotswold E07000079 2 83000 480000
272 Cotswold E07000079 3 130000 608000
273 Cotswold E07000079 4 305000 1271000
274 County Durham E06000047 1 42000 178000
275 County Durham E06000047 2 42000 178000
276 County Durham E06000047 3 55000 227000
277 County Durham E06000047 4 116000 470000
278 Coventry E08000026 1 61000 202000
279 Coventry E08000026 2 80000 202000
280 Coventry E08000026 3 116000 292000
281 Coventry E08000026 4 168000 598000
282 Craven E07000163 1 75000 305000
283 Craven E07000163 2 80000 305000
284 Craven E07000163 3 122000 377000
285 Craven E07000163 4 169000 701000
286 Crawley E07000226 1 122000 330000
287 Crawley E07000226 2 178000 330000
288 Crawley E07000226 3 249000 423000
289 Crawley E07000226 4 309000 627000
290 Croydon E09000008 1 100000 395000
291 Croydon E09000008 2 153000 490000
292 Croydon E09000008 3 299000 612000
293 Croydon E09000008 4 403000 1068000
294 Dacorum E07000096 1 141000 495000
295 Dacorum E07000096 2 184000 495000
296 Dacorum E07000096 3 282000 667000
297 Dacorum E07000096 4 378000 1492000
298 Darlington E06000005 1 43000 183000
299 Darlington E06000005 2 51000 183000
300 Darlington E06000005 3 68000 238000
301 Darlington E06000005 4 139000 469000
302 Dartford E07000107 1 91000 349000
303 Dartford E07000107 2 91000 351000
304 Dartford E07000107 3 243000 473000
305 Dartford E07000107 4 338000 760000
306 Daventry E07000151 1 42000 313000
307 Daventry E07000151 2 67000 313000
308 Daventry E07000151 3 120000 366000
309 Daventry E07000151 4 237000 745000
310 Derby E06000015 1 48000 194000
311 Derby E06000015 2 66000 194000
312 Derby E06000015 3 82000 260000
313 Derby E06000015 4 169000 486000
314 Derbyshire Dales E07000035 1 64000 352000
315 Derbyshire Dales E07000035 2 66000 352000
316 Derbyshire Dales E07000035 3 125000 423000
317 Derbyshire Dales E07000035 4 217000 740000
318 Doncaster E08000017 1 58000 185000
319 Doncaster E08000017 2 58000 185000
320 Doncaster E08000017 3 68000 218000
321 Doncaster E08000017 4 122000 445000
322 Dorset E06000059 1 74000 349000
323 Dorset E06000059 2 109000 349000
324 Dorset E06000059 3 156000 484000
325 Dorset E06000059 4 259000 893000
326 Dover E07000108 1 83000 316000
327 Dover E07000108 2 94000 316000
328 Dover E07000108 3 150000 414000
329 Dover E07000108 4 206000 767000
330 Dudley E08000027 1 53000 216000
331 Dudley E08000027 2 74000 216000
332 Dudley E08000027 3 99000 278000
333 Dudley E08000027 4 152000 471000
334 Ealing E09000009 1 111000 520000
335 Ealing E09000009 2 168000 680000
336 Ealing E09000009 3 297000 968000
337 Ealing E09000009 4 463000 1976000
338 East Cambridgeshire E07000009 1 100000 310000
339 East Cambridgeshire E07000009 2 101000 310000
340 East Cambridgeshire E07000009 3 181000 405000
341 East Cambridgeshire E07000009 4 263000 737000
342 East Devon E07000040 1 67000 340000
343 East Devon E07000040 2 84000 340000
344 East Devon E07000040 3 123000 454000
345 East Devon E07000040 4 240000 839000
346 East Dorset E07000049 1 131000 423000
347 East Dorset E07000049 2 158000 423000
348 East Dorset E07000049 3 229000 516000
349 East Dorset E07000049 4 316000 841000
350 East Hampshire E07000085 1 89000 456000
351 East Hampshire E07000085 2 120000 456000
352 East Hampshire E07000085 3 224000 594000
353 East Hampshire E07000085 4 339000 1201000
354 East Hertfordshire E07000242 1 100000 467000
355 East Hertfordshire E07000242 2 136000 467000
356 East Hertfordshire E07000242 3 277000 654000
357 East Hertfordshire E07000242 4 410000 1265000
358 East Lindsey E07000137 1 52000 236000
359 East Lindsey E07000137 2 58000 236000
360 East Lindsey E07000137 3 81000 276000
361 East Lindsey E07000137 4 136000 536000
362 East Northamptonshire E07000152 1 69000 262000
363 East Northamptonshire E07000152 2 71000 262000
364 East Northamptonshire E07000152 3 133000 328000
365 East Northamptonshire E07000152 4 215000 692000
366 East Riding of Yorkshire E06000011 1 59000 241000
367 East Riding of Yorkshire E06000011 2 74000 241000
368 East Riding of Yorkshire E06000011 3 98000 292000
369 East Riding of Yorkshire E06000011 4 150000 562000
370 East Staffordshire E07000193 1 59000 241000
371 East Staffordshire E07000193 2 73000 241000
372 East Staffordshire E07000193 3 92000 289000
373 East Staffordshire E07000193 4 175000 568000
374 East Suffolk E07000244 1 75000 330000
375 East Suffolk E07000244 2 99000 330000
376 East Suffolk E07000244 3 125000 415000
377 East Suffolk E07000244 4 209000 869000
378 Eastbourne E07000061 1 95000 291000
379 Eastbourne E07000061 2 135000 300000
380 Eastbourne E07000061 3 188000 404000
381 Eastbourne E07000061 4 254000 704000
382 Eastleigh E07000086 1 88000 319000
383 Eastleigh E07000086 2 89000 319000
384 Eastleigh E07000086 3 133000 409000
385 Eastleigh E07000086 4 289000 739000
386 Eden E07000030 1 55000 265000
387 Eden E07000030 2 70000 265000
388 Eden E07000030 3 96000 331000
389 Eden E07000030 4 159000 588000
390 Elmbridge E07000207 1 115000 666000
391 Elmbridge E07000207 2 205000 666000
392 Elmbridge E07000207 3 366000 944000
393 Elmbridge E07000207 4 552000 2294000
394 Enfield E09000010 1 119000 470000
395 Enfield E09000010 2 157000 533000
396 Enfield E09000010 3 302000 770000
397 Enfield E09000010 4 438000 1549000
398 Epping Forest E07000072 1 108000 565000
399 Epping Forest E07000072 2 200000 565000
400 Epping Forest E07000072 3 311000 740000
401 Epping Forest E07000072 4 436000 1665000
402 Epsom and Ewell E07000208 1 179000 544000
403 Epsom and Ewell E07000208 2 245000 544000
404 Epsom and Ewell E07000208 3 345000 749000
405 Epsom and Ewell E07000208 4 491000 1273000
406 Erewash E07000036 1 62000 201000
407 Erewash E07000036 2 73000 201000
408 Erewash E07000036 3 98000 271000
409 Erewash E07000036 4 151000 525000
410 Exeter E07000041 1 79000 296000
411 Exeter E07000041 2 97000 296000
412 Exeter E07000041 3 163000 373000
413 Exeter E07000041 4 242000 757000
414 Fareham E07000087 1 99000 337000
415 Fareham E07000087 2 145000 337000
416 Fareham E07000087 3 208000 425000
417 Fareham E07000087 4 286000 761000
418 Fenland E07000010 1 70000 214000
419 Fenland E07000010 2 96000 214000
420 Fenland E07000010 3 124000 285000
421 Fenland E07000010 4 184000 501000
422 Folkestone and Hythe E07000112 1 82000 332000
423 Folkestone and Hythe E07000112 2 92000 332000
424 Folkestone and Hythe E07000112 3 166000 454000
425 Folkestone and Hythe E07000112 4 226000 771000
426 Forest Heath E07000201 1 61000 247000
427 Forest Heath E07000201 2 110000 247000
428 Forest Heath E07000201 3 125000 323000
429 Forest Heath E07000201 4 198000 548000
430 Forest of Dean E07000080 1 74000 325000
431 Forest of Dean E07000080 2 91000 325000
432 Forest of Dean E07000080 3 127000 393000
433 Forest of Dean E07000080 4 197000 693000
434 Fylde E07000119 1 56000 344000
435 Fylde E07000119 2 79000 293000
436 Fylde E07000119 3 81000 293000
437 Fylde E07000119 4 169000 555000
438 Gateshead E08000037 1 45000 172000
439 Gateshead E08000037 2 52000 172000
440 Gateshead E08000037 3 70000 255000
441 Gateshead E08000037 4 116000 469000
442 Gedling E07000173 1 57000 222000
443 Gedling E07000173 2 75000 222000
444 Gedling E07000173 3 109000 285000
445 Gedling E07000173 4 169000 517000
446 Gloucester E07000081 1 52000 228000
447 Gloucester E07000081 2 85000 228000
448 Gloucester E07000081 3 125000 301000
449 Gloucester E07000081 4 205000 465000
450 Gosport E07000088 1 78000 298000
451 Gosport E07000088 2 109000 299000
452 Gosport E07000088 3 160000 349000
453 Gosport E07000088 4 218000 643000
454 Gravesham E07000109 1 69000 357000
455 Gravesham E07000109 2 99000 357000
456 Gravesham E07000109 3 207000 442000
457 Gravesham E07000109 4 279000 916000
458 Great Yarmouth E07000145 1 70000 220000
459 Great Yarmouth E07000145 2 79000 220000
460 Great Yarmouth E07000145 3 95000 275000
461 Great Yarmouth E07000145 4 146000 481000
462 Greenwich E09000011 1 100000 540000
463 Greenwich E09000011 2 142000 631000
464 Greenwich E09000011 3 249000 792000
465 Greenwich E09000011 4 373000 1668000
466 Guildford E07000209 1 99000 546000
467 Guildford E07000209 2 183000 581000
468 Guildford E07000209 3 303000 791000
469 Guildford E07000209 4 420000 1789000
470 Hackney E09000012 1 165000 612000
471 Hackney E09000012 2 209000 848000
472 Hackney E09000012 3 374000 1280000
473 Hackney E09000012 4 662000 1933000
474 Halton E06000006 1 53000 190000
475 Halton E06000006 2 61000 190000
476 Halton E06000006 3 73000 237000
477 Halton E06000006 4 121000 441000
478 Hambleton E07000164 1 73000 267000
479 Hambleton E07000164 2 88000 267000
480 Hambleton E07000164 3 122000 351000
481 Hambleton E07000164 4 193000 680000
482 Hammersmith and Fulham E09000013 1 178000 697000
483 Hammersmith and Fulham E09000013 2 295000 1054000
484 Hammersmith and Fulham E09000013 3 328000 1657000
485 Hammersmith and Fulham E09000013 4 918000 3040000
486 Harborough E07000131 1 54000 319000
487 Harborough E07000131 2 54000 319000
488 Harborough E07000131 3 119000 384000
489 Harborough E07000131 4 250000 766000
490 Haringey E09000014 1 158000 520000
491 Haringey E09000014 2 240000 753000
492 Haringey E09000014 3 364000 1141000
493 Haringey E09000014 4 549000 2471000
494 Harlow E07000073 1 103000 328000
495 Harlow E07000073 2 130000 337000
496 Harlow E07000073 3 216000 436000
497 Harlow E07000073 4 299000 707000
498 Harrogate E07000165 1 76000 341000
499 Harrogate E07000165 2 89000 341000
500 Harrogate E07000165 3 145000 444000
501 Harrogate E07000165 4 244000 939000
502 Harrow E09000015 1 109000 480000
503 Harrow E09000015 2 257000 549000
504 Harrow E09000015 3 373000 746000
505 Harrow E09000015 4 496000 1414000
506 Hart E07000089 1 85000 446000
507 Hart E07000089 2 116000 446000
508 Hart E07000089 3 267000 567000
509 Hart E07000089 4 406000 1193000
510 Hartlepool E06000001 1 41000 186000
511 Hartlepool E06000001 2 41000 186000
512 Hartlepool E06000001 3 59000 197000
513 Hartlepool E06000001 4 101000 465000
514 Hastings E07000062 1 83000 280000
515 Hastings E07000062 2 125000 304000
516 Hastings E07000062 3 168000 352000
517 Hastings E07000062 4 223000 621000
518 Havant E07000090 1 80000 334000
519 Havant E07000090 2 114000 334000
520 Havant E07000090 3 178000 405000
521 Havant E07000090 4 248000 698000
522 Havering E09000016 1 111000 418000
523 Havering E09000016 2 155000 437000
524 Havering E09000016 3 300000 588000
525 Havering E09000016 4 370000 1048000
526 Herefordshire, County of E06000019 1 73000 307000
527 Herefordshire, County of E06000019 2 73000 307000
528 Herefordshire, County of E06000019 3 121000 373000
529 Herefordshire, County of E06000019 4 204000 672000
530 Hertsmere E07000098 1 157000 540000
531 Hertsmere E07000098 2 240000 540000
532 Hertsmere E07000098 3 354000 757000
533 Hertsmere E07000098 4 468000 1817000
534 High Peak E07000037 1 74000 247000
535 High Peak E07000037 2 94000 247000
536 High Peak E07000037 3 113000 352000
537 High Peak E07000037 4 181000 619000
538 Hillingdon E09000017 1 111000 441000
539 Hillingdon E09000017 2 196000 525000
540 Hillingdon E09000017 3 354000 693000
541 Hillingdon E09000017 4 441000 1280000
542 Hinckley and Bosworth E07000132 1 64000 246000
543 Hinckley and Bosworth E07000132 2 74000 246000
544 Hinckley and Bosworth E07000132 3 109000 315000
545 Hinckley and Bosworth E07000132 4 197000 629000
546 Horsham E07000227 1 73000 433000
547 Horsham E07000227 2 98000 433000
548 Horsham E07000227 3 238000 599000
549 Horsham E07000227 4 391000 1193000
550 Hounslow E09000018 1 96000 507000
551 Hounslow E09000018 2 133000 635000
552 Hounslow E09000018 3 297000 896000
553 Hounslow E09000018 4 419000 2465000
554 Huntingdonshire E07000011 1 70000 308000
555 Huntingdonshire E07000011 2 84000 308000
556 Huntingdonshire E07000011 3 159000 380000
557 Huntingdonshire E07000011 4 251000 668000
558 Hyndburn E07000120 1 48000 166000
559 Hyndburn E07000120 2 48000 166000
560 Hyndburn E07000120 3 62000 216000
561 Hyndburn E07000120 4 116000 391000
562 Ipswich E07000202 1 82000 247000
563 Ipswich E07000202 2 102000 247000
564 Ipswich E07000202 3 144000 319000
565 Ipswich E07000202 4 204000 682000
566 Isle of Wight E06000046 1 78000 283000
567 Isle of Wight E06000046 2 100000 283000
568 Isle of Wight E06000046 3 146000 368000
569 Isle of Wight E06000046 4 197000 701000
570 Islington E09000019 1 171000 672000
571 Islington E09000019 2 291000 1068000
572 Islington E09000019 3 430000 1690000
573 Islington E09000019 4 676000 2918000
574 Kensington and Chelsea E09000020 1 223000 1101000
575 Kensington and Chelsea E09000020 2 538000 2079000
576 Kensington and Chelsea E09000020 3 677000 4300000
577 Kensington and Chelsea E09000020 4 1182000 10727000
578 Kettering E07000153 1 67000 223000
579 Kettering E07000153 2 67000 223000
580 Kettering E07000153 3 119000 292000
581 Kettering E07000153 4 200000 564000
582 King's Lynn and West Norfolk E07000146 1 60000 276000
583 King's Lynn and West Norfolk E07000146 2 96000 276000
584 King's Lynn and West Norfolk E07000146 3 128000 327000
585 King's Lynn and West Norfolk E07000146 4 193000 622000
586 Kingston upon Hull, City of E06000010 1 46000 142000
587 Kingston upon Hull, City of E06000010 2 50000 142000
588 Kingston upon Hull, City of E06000010 3 62000 194000
589 Kingston upon Hull, City of E06000010 4 81000 301000
590 Kingston upon Thames E09000021 1 126000 534000
591 Kingston upon Thames E09000021 2 281000 635000
592 Kingston upon Thames E09000021 3 360000 853000
593 Kingston upon Thames E09000021 4 482000 1761000
594 Kirklees E08000034 1 51000 193000
595 Kirklees E08000034 2 60000 193000
596 Kirklees E08000034 3 84000 273000
597 Kirklees E08000034 4 144000 555000
598 Knowsley E08000011 1 53000 169000
599 Knowsley E08000011 2 53000 169000
600 Knowsley E08000011 3 66000 227000
601 Knowsley E08000011 4 96000 354000
602 Lambeth E09000022 1 137000 579000
603 Lambeth E09000022 2 221000 754000
604 Lambeth E09000022 3 359000 1129000
605 Lambeth E09000022 4 532000 1917000
606 Lancaster E07000121 1 56000 233000
607 Lancaster E07000121 2 70000 233000
608 Lancaster E07000121 3 91000 281000
609 Lancaster E07000121 4 105000 514000
610 Leeds E08000035 1 61000 244000
611 Leeds E08000035 2 72000 244000
612 Leeds E08000035 3 92000 331000
613 Leeds E08000035 4 133000 674000
614 Leicester E06000016 1 35000 213000
615 Leicester E06000016 2 59000 213000
616 Leicester E06000016 3 78000 273000
617 Leicester E06000016 4 172000 532000
618 Lewes E07000063 1 98000 416000
619 Lewes E07000063 2 141000 416000
620 Lewes E07000063 3 205000 579000
621 Lewes E07000063 4 292000 1161000
622 Lewisham E09000023 1 153000 451000
623 Lewisham E09000023 2 213000 597000
624 Lewisham E09000023 3 316000 790000
625 Lewisham E09000023 4 451000 1415000
626 Lichfield E07000194 1 75000 315000
627 Lichfield E07000194 2 75000 315000
628 Lichfield E07000194 3 131000 414000
629 Lichfield E07000194 4 213000 763000
630 Lincoln E07000138 1 31000 188000
631 Lincoln E07000138 2 61000 188000
632 Lincoln E07000138 3 93000 258000
633 Lincoln E07000138 4 141000 421000
634 Liverpool E08000012 1 56000 227000
635 Liverpool E08000012 2 56000 234000
636 Liverpool E08000012 3 68000 280000
637 Liverpool E08000012 4 96000 575000
638 Luton E06000032 1 89000 279000
639 Luton E06000032 2 121000 279000
640 Luton E06000032 3 201000 376000
641 Luton E06000032 4 245000 600000
642 Maidstone E07000110 1 60000 363000
643 Maidstone E07000110 2 96000 363000
644 Maidstone E07000110 3 161000 470000
645 Maidstone E07000110 4 322000 895000
646 Maldon E07000074 1 70000 421000
647 Maldon E07000074 2 98000 421000
648 Maldon E07000074 3 229000 475000
649 Maldon E07000074 4 319000 1063000
650 Malvern Hills E07000235 1 76000 332000
651 Malvern Hills E07000235 2 76000 332000
652 Malvern Hills E07000235 3 120000 432000
653 Malvern Hills E07000235 4 234000 740000
654 Manchester E08000003 1 75000 268000
655 Manchester E08000003 2 76000 328000
656 Manchester E08000003 3 79000 381000
657 Manchester E08000003 4 123000 785000
658 Mansfield E07000174 1 54000 182000
659 Mansfield E07000174 2 59000 182000
660 Mansfield E07000174 3 73000 233000
661 Mansfield E07000174 4 134000 422000
662 Medway E06000035 1 51000 300000
663 Medway E06000035 2 108000 300000
664 Medway E06000035 3 176000 388000
665 Medway E06000035 4 244000 639000
666 Melton E07000133 1 52000 267000
667 Melton E07000133 2 52000 267000
668 Melton E07000133 3 117000 365000
669 Melton E07000133 4 196000 745000
670 Mendip E07000187 1 81000 325000
671 Mendip E07000187 2 82000 325000
672 Mendip E07000187 3 161000 400000
673 Mendip E07000187 4 230000 885000
674 Merton E09000024 1 169000 617000
675 Merton E09000024 2 208000 701000
676 Merton E09000024 3 326000 915000
677 Merton E09000024 4 462000 2637000
678 Mid Devon E07000042 1 78000 307000
679 Mid Devon E07000042 2 85000 307000
680 Mid Devon E07000042 3 138000 387000
681 Mid Devon E07000042 4 213000 725000
682 Mid Suffolk E07000203 1 88000 324000
683 Mid Suffolk E07000203 2 98000 324000
684 Mid Suffolk E07000203 3 174000 416000
685 Mid Suffolk E07000203 4 253000 731000
686 Mid Sussex E07000228 1 136000 435000
687 Mid Sussex E07000228 2 159000 435000
688 Mid Sussex E07000228 3 274000 564000
689 Mid Sussex E07000228 4 376000 1138000
690 Middlesbrough E06000002 1 44000 165000
691 Middlesbrough E06000002 2 49000 165000
692 Middlesbrough E06000002 3 61000 209000
693 Middlesbrough E06000002 4 139000 411000
694 Milton Keynes E06000042 1 52000 302000
695 Milton Keynes E06000042 2 74000 302000
696 Milton Keynes E06000042 3 157000 396000
697 Milton Keynes E06000042 4 283000 741000
698 Mole Valley E07000210 1 128000 577000
699 Mole Valley E07000210 2 180000 577000
700 Mole Valley E07000210 3 338000 787000
701 Mole Valley E07000210 4 480000 1547000
702 New Forest E07000091 1 100000 437000
703 New Forest E07000091 2 148000 437000
704 New Forest E07000091 3 214000 600000
705 New Forest E07000091 4 302000 1173000
706 Newark and Sherwood E07000175 1 62000 260000
707 Newark and Sherwood E07000175 2 62000 260000
708 Newark and Sherwood E07000175 3 83000 298000
709 Newark and Sherwood E07000175 4 158000 636000
710 Newcastle-under-Lyme E07000195 1 67000 183000
711 Newcastle-under-Lyme E07000195 2 67000 183000
712 Newcastle-under-Lyme E07000195 3 87000 261000
713 Newcastle-under-Lyme E07000195 4 154000 521000
714 Newcastle upon Tyne E08000021 1 43000 223000
715 Newcastle upon Tyne E08000021 2 54000 223000
716 Newcastle upon Tyne E08000021 3 67000 293000
717 Newcastle upon Tyne E08000021 4 137000 670000
718 Newham E09000025 1 97000 454000
719 Newham E09000025 2 130000 600000
720 Newham E09000025 3 212000 695000
721 Newham E09000025 4 351000 982000
722 North Devon E07000043 1 69000 311000
723 North Devon E07000043 2 80000 311000
724 North Devon E07000043 3 133000 372000
725 North Devon E07000043 4 183000 615000
726 North Dorset E07000050 1 79000 259000
727 North Dorset E07000050 2 114000 303000
728 North Dorset E07000050 3 177000 392000
729 North Dorset E07000050 4 229000 773000
730 North East Derbyshire E07000038 1 55000 233000
731 North East Derbyshire E07000038 2 57000 233000
732 North East Derbyshire E07000038 3 83000 322000
733 North East Derbyshire E07000038 4 164000 641000
734 North East Lincolnshire E06000012 1 39000 179000
735 North East Lincolnshire E06000012 2 50000 179000
736 North East Lincolnshire E06000012 3 64000 210000
737 North East Lincolnshire E06000012 4 122000 433000
738 North Hertfordshire E07000099 1 86000 421000
739 North Hertfordshire E07000099 2 127000 425000
740 North Hertfordshire E07000099 3 256000 606000
741 North Hertfordshire E07000099 4 358000 1248000
742 North Kesteven E07000139 1 56000 247000
743 North Kesteven E07000139 2 56000 247000
744 North Kesteven E07000139 3 95000 283000
745 North Kesteven E07000139 4 175000 498000
746 North Lincolnshire E06000013 1 50000 212000
747 North Lincolnshire E06000013 2 61000 212000
748 North Lincolnshire E06000013 3 74000 231000
749 North Lincolnshire E06000013 4 130000 421000
750 North Norfolk E07000147 1 85000 345000
751 North Norfolk E07000147 2 103000 345000
752 North Norfolk E07000147 3 134000 417000
753 North Norfolk E07000147 4 200000 834000
754 North Somerset E06000024 1 79000 324000
755 North Somerset E06000024 2 109000 324000
756 North Somerset E06000024 3 165000 433000
757 North Somerset E06000024 4 228000 814000
758 North Tyneside E08000022 1 55000 207000
759 North Tyneside E08000022 2 55000 207000
760 North Tyneside E08000022 3 73000 286000
761 North Tyneside E08000022 4 155000 486000
762 North Warwickshire E07000218 1 77000 266000
763 North Warwickshire E07000218 2 77000 266000
764 North Warwickshire E07000218 3 108000 333000
765 North Warwickshire E07000218 4 190000 703000
766 North West Leicestershire E07000134 1 68000 225000
767 North West Leicestershire E07000134 2 68000 225000
768 North West Leicestershire E07000134 3 95000 298000
769 North West Leicestershire E07000134 4 191000 540000
770 Northampton E07000154 1 42000 221000
771 Northampton E07000154 2 72000 221000
772 Northampton E07000154 3 131000 302000
773 Northampton E07000154 4 204000 558000
774 Northumberland E06000057 1 47000 252000
775 Northumberland E06000057 2 50000 252000
776 Northumberland E06000057 3 71000 283000
777 Northumberland E06000057 4 145000 611000
778 Norwich E07000148 1 69000 212000
779 Norwich E07000148 2 69000 275000
780 Norwich E07000148 3 119000 381000
781 Norwich E07000148 4 187000 814000
782 Nottingham E06000018 1 45000 224000
783 Nottingham E06000018 2 58000 224000
784 Nottingham E06000018 3 64000 260000
785 Nottingham E06000018 4 122000 587000
786 Nuneaton and Bedworth E07000219 1 62000 209000
787 Nuneaton and Bedworth E07000219 2 71000 209000
788 Nuneaton and Bedworth E07000219 3 99000 268000
789 Nuneaton and Bedworth E07000219 4 172000 465000
790 Oadby and Wigston E07000135 1 77000 229000
791 Oadby and Wigston E07000135 2 95000 229000
792 Oadby and Wigston E07000135 3 137000 311000
793 Oadby and Wigston E07000135 4 210000 666000
794 Oldham E08000004 1 59000 197000
795 Oldham E08000004 2 59000 197000
796 Oldham E08000004 3 76000 270000
797 Oldham E08000004 4 119000 541000
798 Oxford E07000178 1 101000 554000
799 Oxford E07000178 2 162000 554000
800 Oxford E07000178 3 260000 652000
801 Oxford E07000178 4 352000 1845000
802 Pendle E07000122 1 43000 189000
803 Pendle E07000122 2 43000 189000
804 Pendle E07000122 3 59000 270000
805 Pendle E07000122 4 107000 496000
806 Peterborough E06000031 1 60000 226000
807 Peterborough E06000031 2 70000 226000
808 Peterborough E06000031 3 114000 273000
809 Peterborough E06000031 4 176000 554000
810 Plymouth E06000026 1 64000 234000
811 Plymouth E06000026 2 70000 234000
812 Plymouth E06000026 3 111000 282000
813 Plymouth E06000026 4 162000 484000
814 Poole E06000029 1 105000 338000
815 Poole E06000029 2 148000 366000
816 Poole E06000029 3 205000 473000
817 Poole E06000029 4 254000 1292000
818 Portsmouth E06000044 1 82000 273000
819 Portsmouth E06000044 2 113000 273000
820 Portsmouth E06000044 3 160000 361000
821 Portsmouth E06000044 4 221000 725000
822 Preston E07000123 1 32000 187000
823 Preston E07000123 2 55000 187000
824 Preston E07000123 3 74000 240000
825 Preston E07000123 4 139000 477000
826 Purbeck E07000051 1 116000 333000
827 Purbeck E07000051 2 155000 403000
828 Purbeck E07000051 3 203000 455000
829 Purbeck E07000051 4 285000 862000
830 Reading E06000038 1 111000 342000
831 Reading E06000038 2 183000 371000
832 Reading E06000038 3 253000 525000
833 Reading E06000038 4 344000 949000
834 Redbridge E09000026 1 86000 440000
835 Redbridge E09000026 2 143000 561000
836 Redbridge E09000026 3 314000 753000
837 Redbridge E09000026 4 432000 1219000
838 Redcar and Cleveland E06000003 1 48000 184000
839 Redcar and Cleveland E06000003 2 48000 184000
840 Redcar and Cleveland E06000003 3 62000 212000
841 Redcar and Cleveland E06000003 4 108000 367000
842 Redditch E07000236 1 45000 222000
843 Redditch E07000236 2 76000 222000
844 Redditch E07000236 3 115000 293000
845 Redditch E07000236 4 179000 467000
846 Reigate and Banstead E07000211 1 109000 469000
847 Reigate and Banstead E07000211 2 125000 469000
848 Reigate and Banstead E07000211 3 300000 694000
849 Reigate and Banstead E07000211 4 409000 1507000
850 Ribble Valley E07000124 1 73000 245000
851 Ribble Valley E07000124 2 73000 245000
852 Ribble Valley E07000124 3 93000 360000
853 Ribble Valley E07000124 4 206000 710000
854 Richmond upon Thames E09000027 1 217000 709000
855 Richmond upon Thames E09000027 2 307000 850000
856 Richmond upon Thames E09000027 3 423000 1209000
857 Richmond upon Thames E09000027 4 612000 2519000
858 Richmondshire E07000166 1 61000 266000
859 Richmondshire E07000166 2 78000 266000
860 Richmondshire E07000166 3 91000 324000
861 Richmondshire E07000166 4 171000 643000
862 Rochdale E08000005 1 50000 165000
863 Rochdale E08000005 2 54000 165000
864 Rochdale E08000005 3 71000 244000
865 Rochdale E08000005 4 129000 460000
866 Rochford E07000075 1 105000 413000
867 Rochford E07000075 2 186000 413000
868 Rochford E07000075 3 253000 478000
869 Rochford E07000075 4 319000 832000
870 Rossendale E07000125 1 44000 197000
871 Rossendale E07000125 2 57000 197000
872 Rossendale E07000125 3 78000 279000
873 Rossendale E07000125 4 134000 506000
874 Rother E07000064 1 67000 373000
875 Rother E07000064 2 104000 373000
876 Rother E07000064 3 187000 512000
877 Rother E07000064 4 282000 913000
878 Rotherham E08000018 1 50000 188000
879 Rotherham E08000018 2 50000 188000
880 Rotherham E08000018 3 66000 229000
881 Rotherham E08000018 4 133000 444000
882 Rugby E07000220 1 78000 246000
883 Rugby E07000220 2 78000 246000
884 Rugby E07000220 3 135000 330000
885 Rugby E07000220 4 224000 598000
886 Runnymede E07000212 1 113000 420000
887 Runnymede E07000212 2 156000 457000
888 Runnymede E07000212 3 320000 659000
889 Runnymede E07000212 4 429000 1450000
890 Rushcliffe E07000176 1 72000 366000
891 Rushcliffe E07000176 2 72000 366000
892 Rushcliffe E07000176 3 130000 392000
893 Rushcliffe E07000176 4 236000 711000
894 Rushmoor E07000092 1 82000 332000
895 Rushmoor E07000092 2 132000 332000
896 Rushmoor E07000092 3 245000 444000
897 Rushmoor E07000092 4 344000 658000
898 Rutland E06000017 1 65000 301000
899 Rutland E06000017 2 65000 301000
900 Rutland E06000017 3 136000 455000
901 Rutland E06000017 4 234000 1033000
902 Ryedale E07000167 1 74000 331000
903 Ryedale E07000167 2 91000 331000
904 Ryedale E07000167 3 129000 369000
905 Ryedale E07000167 4 177000 739000
906 Salford E08000006 1 63000 269000
907 Salford E08000006 2 73000 272000
908 Salford E08000006 3 91000 300000
909 Salford E08000006 4 151000 571000
910 Sandwell E08000028 1 51000 179000
911 Sandwell E08000028 2 70000 179000
912 Sandwell E08000028 3 87000 242000
913 Sandwell E08000028 4 131000 363000
914 Scarborough E07000168 1 47000 218000
915 Scarborough E07000168 2 73000 218000
916 Scarborough E07000168 3 85000 274000
917 Scarborough E07000168 4 117000 483000
918 Sedgemoor E07000188 1 76000 277000
919 Sedgemoor E07000188 2 79000 277000
920 Sedgemoor E07000188 3 126000 355000
921 Sedgemoor E07000188 4 200000 682000
922 Sefton E08000014 1 55000 246000
923 Sefton E08000014 2 62000 246000
924 Sefton E08000014 3 76000 284000
925 Sefton E08000014 4 124000 596000
926 Selby E07000169 1 61000 232000
927 Selby E07000169 2 69000 232000
928 Selby E07000169 3 92000 285000
929 Selby E07000169 4 187000 518000
930 Sevenoaks E07000111 1 132000 551000
931 Sevenoaks E07000111 2 132000 551000
932 Sevenoaks E07000111 3 249000 751000
933 Sevenoaks E07000111 4 381000 1843000
934 Sheffield E08000019 1 56000 239000
935 Sheffield E08000019 2 59000 239000
936 Sheffield E08000019 3 79000 318000
937 Sheffield E08000019 4 149000 722000
938 Shropshire E06000051 1 66000 298000
939 Shropshire E06000051 2 78000 298000
940 Shropshire E06000051 3 116000 349000
941 Shropshire E06000051 4 188000 641000
942 Slough E06000039 1 122000 345000
943 Slough E06000039 2 172000 366000
944 Slough E06000039 3 277000 542000
945 Slough E06000039 4 349000 841000
946 Solihull E08000029 1 71000 379000
947 Solihull E08000029 2 90000 379000
948 Solihull E08000029 3 119000 422000
949 Solihull E08000029 4 243000 920000
950 Somerset West and Taunton E07000246 1 82000 307000
951 Somerset West and Taunton E07000246 2 101000 307000
952 Somerset West and Taunton E07000246 3 156000 381000
953 Somerset West and Taunton E07000246 4 223000 752000
954 South Bucks E07000006 1 98000 671000
955 South Bucks E07000006 2 158000 671000
956 South Bucks E07000006 3 339000 884000
957 South Bucks E07000006 4 513000 1889000
958 South Cambridgeshire E07000012 1 105000 410000
959 South Cambridgeshire E07000012 2 130000 410000
960 South Cambridgeshire E07000012 3 207000 539000
961 South Cambridgeshire E07000012 4 324000 959000
962 South Derbyshire E07000039 1 71000 226000
963 South Derbyshire E07000039 2 73000 226000
964 South Derbyshire E07000039 3 100000 276000
965 South Derbyshire E07000039 4 184000 546000
966 South Gloucestershire E06000025 1 67000 300000
967 South Gloucestershire E06000025 2 104000 300000
968 South Gloucestershire E06000025 3 190000 383000
969 South Gloucestershire E06000025 4 283000 670000
970 South Hams E07000044 1 79000 423000
971 South Hams E07000044 2 79000 423000
972 South Hams E07000044 3 150000 526000
973 South Hams E07000044 4 239000 948000
974 South Holland E07000140 1 57000 214000
975 South Holland E07000140 2 57000 214000
976 South Holland E07000140 3 101000 276000
977 South Holland E07000140 4 173000 470000
978 South Kesteven E07000141 1 62000 264000
979 South Kesteven E07000141 2 68000 264000
980 South Kesteven E07000141 3 98000 324000
981 South Kesteven E07000141 4 184000 649000
982 South Lakeland E07000031 1 69000 318000
983 South Lakeland E07000031 2 89000 318000
984 South Lakeland E07000031 3 122000 395000
985 South Lakeland E07000031 4 195000 660000
986 South Norfolk E07000149 1 88000 291000
987 South Norfolk E07000149 2 88000 291000
988 South Norfolk E07000149 3 171000 382000
989 South Norfolk E07000149 4 236000 645000
990 South Northamptonshire E07000155 1 85000 348000
991 South Northamptonshire E07000155 2 85000 348000
992 South Northamptonshire E07000155 3 163000 397000
993 South Northamptonshire E07000155 4 279000 825000
994 South Oxfordshire E07000179 1 106000 492000
995 South Oxfordshire E07000179 2 123000 492000
996 South Oxfordshire E07000179 3 191000 616000
997 South Oxfordshire E07000179 4 349000 1554000
998 South Ribble E07000126 1 70000 209000
999 South Ribble E07000126 2 72000 209000
1000 South Ribble E07000126 3 95000 246000
1001 South Ribble E07000126 4 156000 484000
1002 South Somerset E07000189 1 70000 275000
1003 South Somerset E07000189 2 99000 275000
1004 South Somerset E07000189 3 131000 358000
1005 South Somerset E07000189 4 202000 735000
1006 South Staffordshire E07000196 1 69000 275000
1007 South Staffordshire E07000196 2 70000 275000
1008 South Staffordshire E07000196 3 121000 341000
1009 South Staffordshire E07000196 4 194000 694000
1010 South Tyneside E08000023 1 43000 192000
1011 South Tyneside E08000023 2 50000 192000
1012 South Tyneside E08000023 3 61000 250000
1013 South Tyneside E08000023 4 123000 460000
1014 Southampton E06000045 1 67000 213000
1015 Southampton E06000045 2 113000 273000
1016 Southampton E06000045 3 169000 363000
1017 Southampton E06000045 4 211000 637000
1018 Southend-on-Sea E06000033 1 103000 384000
1019 Southend-on-Sea E06000033 2 117000 417000
1020 Southend-on-Sea E06000033 3 220000 524000
1021 Southend-on-Sea E06000033 4 299000 901000
1022 Southwark E09000028 1 130000 597000
1023 Southwark E09000028 2 165000 818000
1024 Southwark E09000028 3 300000 1147000
1025 Southwark E09000028 4 512000 2119000
1026 Spelthorne E07000213 1 177000 450000
1027 Spelthorne E07000213 2 232000 462000
1028 Spelthorne E07000213 3 311000 603000
1029 Spelthorne E07000213 4 415000 973000
1030 St Albans E07000240 1 156000 648000
1031 St Albans E07000240 2 250000 648000
1032 St Albans E07000240 3 355000 854000
1033 St Albans E07000240 4 532000 1739000
1034 St Edmundsbury E07000204 1 96000 320000
1035 St Edmundsbury E07000204 2 122000 320000
1036 St Edmundsbury E07000204 3 171000 410000
1037 St Edmundsbury E07000204 4 236000 776000
1038 St. Helens E08000013 1 55000 165000
1039 St. Helens E08000013 2 55000 165000
1040 St. Helens E08000013 3 69000 235000
1041 St. Helens E08000013 4 129000 478000
1042 Stafford E07000197 1 61000 257000
1043 Stafford E07000197 2 66000 257000
1044 Stafford E07000197 3 109000 315000
1045 Stafford E07000197 4 185000 569000
1046 Staffordshire Moorlands E07000198 1 57000 267000
1047 Staffordshire Moorlands E07000198 2 78000 267000
1048 Staffordshire Moorlands E07000198 3 101000 328000
1049 Staffordshire Moorlands E07000198 4 148000 586000
1050 Stevenage E07000243 1 68000 315000
1051 Stevenage E07000243 2 87000 320000
1052 Stevenage E07000243 3 232000 399000
1053 Stevenage E07000243 4 274000 656000
1054 Stockport E08000007 1 68000 288000
1055 Stockport E08000007 2 72000 288000
1056 Stockport E08000007 3 125000 402000
1057 Stockport E08000007 4 217000 808000
1058 Stockton-on-Tees E06000004 1 45000 192000
1059 Stockton-on-Tees E06000004 2 45000 192000
1060 Stockton-on-Tees E06000004 3 65000 227000
1061 Stockton-on-Tees E06000004 4 134000 491000
1062 Stoke-on-Trent E06000021 1 50000 151000
1063 Stoke-on-Trent E06000021 2 51000 151000
1064 Stoke-on-Trent E06000021 3 62000 216000
1065 Stoke-on-Trent E06000021 4 125000 379000
1066 Stratford-on-Avon E07000221 1 87000 357000
1067 Stratford-on-Avon E07000221 2 87000 357000
1068 Stratford-on-Avon E07000221 3 145000 493000
1069 Stratford-on-Avon E07000221 4 277000 1020000
1070 Stroud E07000082 1 72000 326000
1071 Stroud E07000082 2 89000 326000
1072 Stroud E07000082 3 164000 453000
1073 Stroud E07000082 4 239000 888000
1074 Suffolk Coastal E07000205 1 79000 357000
1075 Suffolk Coastal E07000205 2 126000 387000
1076 Suffolk Coastal E07000205 3 168000 420000
1077 Suffolk Coastal E07000205 4 244000 747000
1078 Sunderland E08000024 1 44000 165000
1079 Sunderland E08000024 2 51000 165000
1080 Sunderland E08000024 3 62000 217000
1081 Sunderland E08000024 4 114000 413000
1082 Surrey Heath E07000214 1 116000 472000
1083 Surrey Heath E07000214 2 116000 472000
1084 Surrey Heath E07000214 3 294000 598000
1085 Surrey Heath E07000214 4 416000 1173000
1086 Sutton E09000029 1 110000 432000
1087 Sutton E09000029 2 189000 445000
1088 Sutton E09000029 3 312000 616000
1089 Sutton E09000029 4 432000 1171000
1090 Swale E07000113 1 88000 303000
1091 Swale E07000113 2 102000 303000
1092 Swale E07000113 3 163000 389000
1093 Swale E07000113 4 253000 751000
1094 Swindon E06000030 1 80000 243000
1095 Swindon E06000030 2 91000 243000
1096 Swindon E06000030 3 151000 322000
1097 Swindon E06000030 4 235000 576000
1098 Tameside E08000008 1 69000 177000
1099 Tameside E08000008 2 78000 177000
1100 Tameside E08000008 3 99000 252000
1101 Tameside E08000008 4 143000 490000
1102 Tamworth E07000199 1 66000 211000
1103 Tamworth E07000199 2 74000 211000
1104 Tamworth E07000199 3 112000 285000
1105 Tamworth E07000199 4 173000 462000
1106 Tandridge E07000215 1 107000 493000
1107 Tandridge E07000215 2 164000 493000
1108 Tandridge E07000215 3 316000 692000
1109 Tandridge E07000215 4 431000 1649000
1110 Taunton Deane E07000190 1 77000 249000
1111 Taunton Deane E07000190 2 78000 249000
1112 Taunton Deane E07000190 3 135000 325000
1113 Taunton Deane E07000190 4 210000 657000
1114 Teignbridge E07000045 1 74000 310000
1115 Teignbridge E07000045 2 84000 310000
1116 Teignbridge E07000045 3 142000 392000
1117 Teignbridge E07000045 4 217000 714000
1118 Telford and Wrekin E06000020 1 61000 202000
1119 Telford and Wrekin E06000020 2 68000 202000
1120 Telford and Wrekin E06000020 3 86000 258000
1121 Telford and Wrekin E06000020 4 152000 484000
1122 Tendring E07000076 1 71000 295000
1123 Tendring E07000076 2 111000 295000
1124 Tendring E07000076 3 150000 382000
1125 Tendring E07000076 4 222000 739000
1126 Test Valley E07000093 1 77000 405000
1127 Test Valley E07000093 2 90000 405000
1128 Test Valley E07000093 3 164000 470000
1129 Test Valley E07000093 4 287000 999000
1130 Tewkesbury E07000083 1 55000 298000
1131 Tewkesbury E07000083 2 75000 298000
1132 Tewkesbury E07000083 3 120000 404000
1133 Tewkesbury E07000083 4 255000 720000
1134 Thanet E07000114 1 80000 297000
1135 Thanet E07000114 2 119000 297000
1136 Thanet E07000114 3 165000 390000
1137 Thanet E07000114 4 229000 701000
1138 Three Rivers E07000102 1 191000 530000
1139 Three Rivers E07000102 2 204000 613000
1140 Three Rivers E07000102 3 334000 796000
1141 Three Rivers E07000102 4 480000 1730000
1142 Thurrock E06000034 1 103000 327000
1143 Thurrock E06000034 2 134000 327000
1144 Thurrock E06000034 3 221000 408000
1145 Thurrock E06000034 4 299000 647000
1146 Tonbridge and Malling E07000115 1 101000 375000
1147 Tonbridge and Malling E07000115 2 106000 375000
1148 Tonbridge and Malling E07000115 3 236000 565000
1149 Tonbridge and Malling E07000115 4 345000 1080000
1150 Torbay E06000027 1 67000 295000
1151 Torbay E06000027 2 89000 295000
1152 Torbay E06000027 3 127000 334000
1153 Torbay E06000027 4 168000 606000
1154 Torridge E07000046 1 81000 279000
1155 Torridge E07000046 2 100000 279000
1156 Torridge E07000046 3 132000 375000
1157 Torridge E07000046 4 188000 611000
1158 Tower Hamlets E09000030 1 131000 564000
1159 Tower Hamlets E09000030 2 181000 806000
1160 Tower Hamlets E09000030 3 230000 1253000
1161 Tower Hamlets E09000030 4 430000 1616000
1162 Trafford E08000009 1 78000 377000
1163 Trafford E08000009 2 109000 377000
1164 Trafford E08000009 3 149000 473000
1165 Trafford E08000009 4 245000 1241000
1166 Tunbridge Wells E07000116 1 85000 471000
1167 Tunbridge Wells E07000116 2 121000 471000
1168 Tunbridge Wells E07000116 3 259000 677000
1169 Tunbridge Wells E07000116 4 389000 1408000
1170 Uttlesford E07000077 1 60000 448000
1171 Uttlesford E07000077 2 111000 448000
1172 Uttlesford E07000077 3 217000 566000
1173 Uttlesford E07000077 4 376000 1179000
1174 Vale of White Horse E07000180 1 73000 381000
1175 Vale of White Horse E07000180 2 104000 381000
1176 Vale of White Horse E07000180 3 209000 483000
1177 Vale of White Horse E07000180 4 329000 947000
1178 Wakefield E08000036 1 57000 174000
1179 Wakefield E08000036 2 64000 174000
1180 Wakefield E08000036 3 78000 243000
1181 Wakefield E08000036 4 141000 450000
1182 Walsall E08000030 1 59000 198000
1183 Walsall E08000030 2 71000 198000
1184 Walsall E08000030 3 88000 281000
1185 Walsall E08000030 4 143000 605000
1186 Waltham Forest E09000031 1 126000 467000
1187 Waltham Forest E09000031 2 212000 574000
1188 Waltham Forest E09000031 3 360000 744000
1189 Waltham Forest E09000031 4 451000 997000
1190 Wandsworth E09000032 1 154000 629000
1191 Wandsworth E09000032 2 253000 859000
1192 Wandsworth E09000032 3 403000 1259000
1193 Wandsworth E09000032 4 711000 2487000
1194 Warrington E06000007 1 63000 256000
1195 Warrington E06000007 2 76000 256000
1196 Warrington E06000007 3 98000 335000
1197 Warrington E06000007 4 177000 715000
1198 Warwick E07000222 1 70000 359000
1199 Warwick E07000222 2 102000 359000
1200 Warwick E07000222 3 182000 467000
1201 Warwick E07000222 4 306000 924000
1202 Watford E07000103 1 134000 406000
1203 Watford E07000103 2 211000 431000
1204 Watford E07000103 3 322000 674000
1205 Watford E07000103 4 417000 1172000
1206 Waveney E07000206 1 62000 271000
1207 Waveney E07000206 2 89000 271000
1208 Waveney E07000206 3 105000 291000
1209 Waveney E07000206 4 150000 570000
1210 Waverley E07000216 1 118000 576000
1211 Waverley E07000216 2 150000 576000
1212 Waverley E07000216 3 299000 738000
1213 Waverley E07000216 4 446000 1825000
1214 Wealden E07000065 1 99000 415000
1215 Wealden E07000065 2 113000 415000
1216 Wealden E07000065 3 199000 570000
1217 Wealden E07000065 4 310000 1260000
1218 Wellingborough E07000156 1 26000 254000
1219 Wellingborough E07000156 2 50000 254000
1220 Wellingborough E07000156 3 124000 313000
1221 Wellingborough E07000156 4 202000 685000
1222 Welwyn Hatfield E07000241 1 80000 439000
1223 Welwyn Hatfield E07000241 2 118000 487000
1224 Welwyn Hatfield E07000241 3 269000 693000
1225 Welwyn Hatfield E07000241 4 387000 1402000
1226 West Berkshire E06000037 1 82000 439000
1227 West Berkshire E06000037 2 104000 439000
1228 West Berkshire E06000037 3 241000 546000
1229 West Berkshire E06000037 4 357000 1256000
1230 West Devon E07000047 1 73000 333000
1231 West Devon E07000047 2 106000 333000
1232 West Devon E07000047 3 149000 416000
1233 West Devon E07000047 4 194000 765000
1234 West Dorset E07000052 1 97000 327000
1235 West Dorset E07000052 2 106000 327000
1236 West Dorset E07000052 3 168000 432000
1237 West Dorset E07000052 4 247000 846000
1238 West Lancashire E07000127 1 41000 296000
1239 West Lancashire E07000127 2 58000 296000
1240 West Lancashire E07000127 3 58000 314000
1241 West Lancashire E07000127 4 117000 648000
1242 West Lindsey E07000142 1 59000 234000
1243 West Lindsey E07000142 2 59000 234000
1244 West Lindsey E07000142 3 81000 290000
1245 West Lindsey E07000142 4 141000 522000
1246 West Oxfordshire E07000181 1 90000 407000
1247 West Oxfordshire E07000181 2 94000 407000
1248 West Oxfordshire E07000181 3 168000 524000
1249 West Oxfordshire E07000181 4 300000 982000
1250 West Somerset E07000191 1 86000 333000
1251 West Somerset E07000191 2 103000 333000
1252 West Somerset E07000191 3 152000 357000
1253 West Somerset E07000191 4 207000 798000
1254 West Suffolk E07000245 1 65000 300000
1255 West Suffolk E07000245 2 86000 300000
1256 West Suffolk E07000245 3 138000 410000
1257 West Suffolk E07000245 4 250000 798000
1258 Westminster E09000033 1 245000 879000
1259 Westminster E09000033 2 430000 1846000
1260 Westminster E09000033 3 501000 2876000
1261 Westminster E09000033 4 914000 7794000
1262 Weymouth and Portland E07000053 1 69000 255000
1263 Weymouth and Portland E07000053 2 104000 255000
1264 Weymouth and Portland E07000053 3 154000 335000
1265 Weymouth and Portland E07000053 4 201000 547000
1266 Wigan E08000010 1 58000 181000
1267 Wigan E08000010 2 58000 181000
1268 Wigan E08000010 3 70000 239000
1269 Wigan E08000010 4 140000 399000
1270 Wiltshire E06000054 1 76000 325000
1271 Wiltshire E06000054 2 89000 325000
1272 Wiltshire E06000054 3 160000 430000
1273 Wiltshire E06000054 4 250000 863000
1274 Winchester E07000094 1 80000 516000
1275 Winchester E07000094 2 103000 516000
1276 Winchester E07000094 3 230000 729000
1277 Winchester E07000094 4 371000 1384000
1278 Windsor and Maidenhead E06000040 1 177000 556000
1279 Windsor and Maidenhead E06000040 2 239000 561000
1280 Windsor and Maidenhead E06000040 3 334000 816000
1281 Windsor and Maidenhead E06000040 4 474000 1683000
1282 Wirral E08000015 1 53000 249000
1283 Wirral E08000015 2 62000 249000
1284 Wirral E08000015 3 79000 283000
1285 Wirral E08000015 4 116000 619000
1286 Woking E07000217 1 150000 443000
1287 Woking E07000217 2 220000 454000
1288 Woking E07000217 3 309000 698000
1289 Woking E07000217 4 436000 1373000
1290 Wokingham E06000041 1 99000 428000
1291 Wokingham E06000041 2 112000 428000
1292 Wokingham E06000041 3 231000 551000
1293 Wokingham E06000041 4 411000 1039000
1294 Wolverhampton E08000031 1 30000 200000
1295 Wolverhampton E08000031 2 47000 200000
1296 Wolverhampton E08000031 3 76000 252000
1297 Wolverhampton E08000031 4 125000 526000
1298 Worcester E07000237 1 63000 231000
1299 Worcester E07000237 2 95000 231000
1300 Worcester E07000237 3 133000 322000
1301 Worcester E07000237 4 204000 572000
1302 Worthing E07000229 1 117000 366000
1303 Worthing E07000229 2 147000 371000
1304 Worthing E07000229 3 238000 473000
1305 Worthing E07000229 4 313000 718000
1306 Wychavon E07000238 1 74000 338000
1307 Wychavon E07000238 2 74000 338000
1308 Wychavon E07000238 3 123000 406000
1309 Wychavon E07000238 4 234000 722000
1310 Wycombe E07000007 1 134000 501000
1311 Wycombe E07000007 2 168000 501000
1312 Wycombe E07000007 3 273000 631000
1313 Wycombe E07000007 4 376000 1385000
1314 Wyre E07000128 1 51000 226000
1315 Wyre E07000128 2 61000 226000
1316 Wyre E07000128 3 81000 271000
1317 Wyre E07000128 4 147000 484000
1318 Wyre Forest E07000239 1 68000 255000
1319 Wyre Forest E07000239 2 68000 255000
1320 Wyre Forest E07000239 3 106000 294000
1321 Wyre Forest E07000239 4 170000 689000
1322 York E06000014 1 79000 322000
1323 York E06000014 2 126000 322000
1324 York E06000014 3 161000 397000
1325 York E06000014 4 236000 731000
1326 Other 1 40000 399000
1327 Other 2 60000 499000
1328 Other 3 100000 799000
1329 Other 4 120000 999000

6
db/migrate/20230124111328_create_la_purchase_price_ranges.rb → db/migrate/20230124111328_create_la_sale_ranges.rb

@ -1,13 +1,13 @@
class CreateLaPurchasePriceRanges < ActiveRecord::Migration[7.0]
class CreateLaSaleRanges < ActiveRecord::Migration[7.0]
def change
create_table :la_purchase_price_ranges do |t|
create_table :la_sale_ranges do |t|
t.string :la
t.integer :bedrooms
t.decimal :soft_min, precision: 10, scale: 2
t.decimal :soft_max, precision: 10, scale: 2
t.integer :start_year
t.index %i[start_year bedrooms la], unique: true, name: "index_la_purchase_price_ranges_on_start_year_bedrooms_la"
t.index %i[start_year bedrooms la], unique: true, name: "index_la_sale_ranges_on_start_year_bedrooms_la"
t.timestamps
end
end

20
db/schema.rb

@ -54,30 +54,30 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_24_111328) do
t.index ["organisation_id"], name: "index_data_protection_confirmations_on_organisation_id"
end
create_table "la_purchase_price_ranges", force: :cascade do |t|
create_table "la_rent_ranges", force: :cascade do |t|
t.integer "ranges_rent_id"
t.integer "lettype"
t.string "la"
t.integer "bedrooms"
t.integer "beds"
t.decimal "soft_min", precision: 10, scale: 2
t.decimal "soft_max", precision: 10, scale: 2
t.decimal "hard_min", precision: 10, scale: 2
t.decimal "hard_max", precision: 10, scale: 2
t.integer "start_year"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["start_year", "bedrooms", "la"], name: "index_la_purchase_price_ranges_on_start_year_bedrooms_la", unique: true
t.index ["start_year", "lettype", "beds", "la"], name: "index_la_rent_ranges_on_start_year_and_lettype_and_beds_and_la", unique: true
end
create_table "la_rent_ranges", force: :cascade do |t|
t.integer "ranges_rent_id"
t.integer "lettype"
create_table "la_sale_ranges", force: :cascade do |t|
t.string "la"
t.integer "beds"
t.integer "bedrooms"
t.decimal "soft_min", precision: 10, scale: 2
t.decimal "soft_max", precision: 10, scale: 2
t.decimal "hard_min", precision: 10, scale: 2
t.decimal "hard_max", precision: 10, scale: 2
t.integer "start_year"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["start_year", "lettype", "beds", "la"], name: "index_la_rent_ranges_on_start_year_and_lettype_and_beds_and_la", unique: true
t.index ["start_year", "bedrooms", "la"], name: "index_la_sale_ranges_on_start_year_bedrooms_la", unique: true
end
create_table "legacy_users", force: :cascade do |t|

4
db/seeds.rb

@ -311,8 +311,8 @@ unless Rails.env.test?
end
end
if LaPurchasePriceRange.count.zero?
Dir.glob("config/purchase_price_range_data/*.csv").each do |path|
if LaSaleRange.count.zero?
Dir.glob("config/sale_range_data/*.csv").each do |path|
start_year = File.basename(path, ".csv")
service = Imports::PurchasePriceRangesService.new(start_year:, path:)
service.call

14
lib/tasks/purchase_price_ranges.rake

@ -1,14 +0,0 @@
namespace :data_import do
desc "Import annual purchase price range data"
task :purchase_price_ranges, %i[start_year path] => :environment do |_task, args|
start_year = args[:start_year]
path = args[:path]
raise "Usage: rake data_import:purchase_price_ranges[start_year,'path/to/csv_file']" if path.blank? || start_year.blank?
service = Imports::PurchasePriceRangesService.new(start_year:, path:)
service.call
pp "Created/updated #{service.count} LA Purchase Price Range records for #{start_year}" unless Rails.env.test?
end
end

14
lib/tasks/sale_ranges.rake

@ -0,0 +1,14 @@
namespace :data_import do
desc "Import annual sale range data"
task :sale_ranges, %i[start_year path] => :environment do |_task, args|
start_year = args[:start_year]
path = args[:path]
raise "Usage: rake data_import:sale_ranges[start_year,'path/to/csv_file']" if path.blank? || start_year.blank?
service = Imports::SaleRangesService.new(start_year:, path:)
service.call
pp "Created/updated #{service.count} LA Sale Range records for #{start_year}" unless Rails.env.test?
end
end

0
spec/fixtures/files/purchase_price_ranges.csv → spec/fixtures/files/sale_ranges.csv vendored

1 la_name la bedrooms soft_min soft_max
2 Adur E07000223 1 105000 369000
3 Adur E07000223 2 177000 384000
4 Adur E07000223 3 246000 539000
5 Adur E07000223 4 310000 860000

47
spec/lib/tasks/purchase_price_range_import_spec.rb

@ -1,47 +0,0 @@
require "rails_helper"
require "rake"
RSpec.describe "data_import" do
describe ":purchase_price_ranges", type: :task do
subject(:task) { Rake::Task["data_import:purchase_price_ranges"] }
before do
Rake.application.rake_require("tasks/purchase_price_ranges")
Rake::Task.define_task(:environment)
task.reenable
end
context "when the rake task is run" do
let(:start_year) { 2022 }
let(:purchase_price_ranges_file_path) { "./spec/fixtures/files/purchase_price_ranges.csv" }
let(:wrong_file_path) { "/test/no_csv_here.csv" }
it "creates new rent range records" do
expect { task.invoke(start_year, purchase_price_ranges_file_path) }.to change(LaPurchasePriceRange, :count).by(4)
expect(LaPurchasePriceRange.where(bedrooms: 1).exists?).to be true
end
it "raises an error when no path is given" do
expect { task.invoke(start_year, nil) }.to raise_error(RuntimeError, "Usage: rake data_import:purchase_price_ranges[start_year,'path/to/csv_file']")
end
it "raises an error when no file exists at the given path" do
expect { task.invoke(start_year, wrong_file_path) }.to raise_error(Errno::ENOENT)
end
it "asks for a start year if it is not given" do
expect { task.invoke(nil, purchase_price_ranges_file_path) }.to raise_error(RuntimeError, "Usage: rake data_import:purchase_price_ranges[start_year,'path/to/csv_file']")
end
context "when a record already exists with a matching index of la, bedrooms and start year" do
let!(:purchase_price_range) { LaPurchasePriceRange.create(la: "E07000223", bedrooms: 2, soft_min: 177_000, soft_max: 384_000, start_year: 2022) }
it "updates rent ranges if the record is matched on la, bedrooms and start year" do
task.invoke(start_year, purchase_price_ranges_file_path)
purchase_price_range.reload
expect(purchase_price_range.soft_max).to eq(384_000)
end
end
end
end
end

47
spec/lib/tasks/sale_range_import_spec.rb

@ -0,0 +1,47 @@
require "rails_helper"
require "rake"
RSpec.describe "data_import" do
describe ":sale_ranges", type: :task do
subject(:task) { Rake::Task["data_import:sale_ranges"] }
before do
Rake.application.rake_require("tasks/sale_ranges")
Rake::Task.define_task(:environment)
task.reenable
end
context "when the rake task is run" do
let(:start_year) { 2022 }
let(:sale_ranges_file_path) { "./spec/fixtures/files/sale_ranges.csv" }
let(:wrong_file_path) { "/test/no_csv_here.csv" }
it "creates new rent range records" do
expect { task.invoke(start_year, sale_ranges_file_path) }.to change(LaSaleRange, :count).by(4)
expect(LaSaleRange.where(bedrooms: 1).exists?).to be true
end
it "raises an error when no path is given" do
expect { task.invoke(start_year, nil) }.to raise_error(RuntimeError, "Usage: rake data_import:sale_ranges[start_year,'path/to/csv_file']")
end
it "raises an error when no file exists at the given path" do
expect { task.invoke(start_year, wrong_file_path) }.to raise_error(Errno::ENOENT)
end
it "asks for a start year if it is not given" do
expect { task.invoke(nil, sale_ranges_file_path) }.to raise_error(RuntimeError, "Usage: rake data_import:sale_ranges[start_year,'path/to/csv_file']")
end
context "when a record already exists with a matching index of la, bedrooms and start year" do
let!(:sale_range) { LaSaleRange.create(la: "E07000223", bedrooms: 2, soft_min: 177_000, soft_max: 384_000, start_year: 2022) }
it "updates rent ranges if the record is matched on la, bedrooms and start year" do
task.invoke(start_year, sale_ranges_file_path)
sale_range.reload
expect(sale_range.soft_max).to eq(384_000)
end
end
end
end
end

2
spec/models/validations/sales/soft_validations_spec.rb

@ -332,7 +332,7 @@ RSpec.describe Validations::Sales::SoftValidations do
describe "purchase_price_out_of_soft_range" do
before do
LaPurchasePriceRange.create!(
LaSaleRange.create!(
la: "E07000223",
bedrooms: 2,
soft_min: 177_000,

Loading…
Cancel
Save