rcpch / rcpch-census-platform

A Django-rest-framework project to return deprivation scores across the UK against a postcode or lsoa code
MIT License
0 stars 1 forks source link

Remove redundant postcode validation #23

Closed mbarton closed 3 months ago

mbarton commented 3 months ago

/validate does the same underlying database lookup at their end as the normal API so we don't need the additional call. This makes the API about twice as fast.

Before

time curl 'http://localhost:8001/index_of_multiple_deprivation_quantile?postcode=W1A1AA&quantile=5'
{"result":{"rank":15472,"requested_quantile":5,"requested_quantile_name":"quintile","data_quantile":3,"country":"england","error":null}}
real    0m0.186s
user    0m0.002s
sys     0m0.003s

After

time curl 'http://localhost:8001/index_of_multiple_deprivation_quantile?postcode=W1A1AA&quantile=5'
{"result":{"rank":15472,"requested_quantile":5,"requested_quantile_name":"quintile","data_quantile":3,"country":"england","error":null}}
real    0m0.103s
user    0m0.002s
sys     0m0.003s
pacharanero commented 3 months ago

I can't see any difference between Before and After in the first post...

mbarton commented 3 months ago

Whoops, have updated with the correct timings

pacharanero commented 3 months ago

Aha yes much faster

anchit-chandran commented 3 months ago

this is a fantastically simple improvement, really good catch! LGTM