mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
chore: add includes call to ensure we don't do an n+1 query
This commit is contained in:
parent
138c61e7f0
commit
4331c01789
1 changed files with 5 additions and 5 deletions
|
|
@ -1,12 +1,12 @@
|
||||||
class SocioEconomicCalculator
|
class SocioEconomicCalculator
|
||||||
def self.update_socio_economic_scores
|
def self.update_socio_economic_scores
|
||||||
parent_list = [].tap do |list|
|
parent_list = [].tap do |list|
|
||||||
Parent.all.each do |parent|
|
Parent.includes(:employments, :benefit, :education).all.each do |parent|
|
||||||
parent.socio_economic_status = if has_all_socio_economic_data?(parent:)
|
parent.socio_economic_status = if has_all_socio_economic_data?(parent:)
|
||||||
socio_economic_score(parent.education, parent.benefit, parent.employments)
|
socio_economic_score(parent.education, parent.benefit, parent.employments)
|
||||||
else
|
else
|
||||||
-1
|
-1
|
||||||
end
|
end
|
||||||
|
|
||||||
list << parent
|
list << parent
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue