mysociety / mapit

A web service to map postcodes to administrative boundaries and more
Other
269 stars 88 forks source link

Manually prefetch any matching many-many countries #319

Closed dracos closed 6 years ago

dracos commented 6 years ago

iterator() and prefetch() can't be used together, so the prefetch of many-many countries is not happening in area lists, causing a slowdown if many areas are to be returned. Instead, as we already do with codes, we manually fetch all of the relevant countries from the join table and store them on the model objects as we iterate through them.

codecov[bot] commented 6 years ago

Codecov Report

Merging #319 into master will decrease coverage by 0.08%. The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #319      +/-   ##
==========================================
- Coverage   62.83%   62.74%   -0.09%     
==========================================
  Files          38       38              
  Lines        2155     2158       +3     
==========================================
  Hits         1354     1354              
- Misses        801      804       +3
Impacted Files Coverage Δ
mapit/models.py 83.25% <100%> (-0.31%) :arrow_down:
mapit/views/areas.py 67.73% <57.14%> (-0.25%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6b97ed3...230093b. Read the comment docs.

dracos commented 6 years ago

Edited post merge to include blank results too, as we want a negative cache result as well (the only result on UK, after all).