PERF: release results in a couple of cases

This commit is contained in:
Sam 2018-06-13 15:11:43 +10:00
parent 139d0813b4
commit 12fd0b827e
2 changed files with 6 additions and 2 deletions

View File

@ -33,7 +33,8 @@ module Jobs
HAVING COUNT(p.id) > 0 AND COUNT(ub.id) = 0
SQL
user_ids = results.map { |r| r['user_id'].to_i }
user_ids = results.column_values(0)
results.clear
User.where(id: user_ids).find_each do |user|
BadgeGranter.grant(badge, user, created_at: end_date)

View File

@ -82,7 +82,10 @@ module Jobs
LIMIT #{MAX_AWARDED}
SQL
User.exec_sql(sql).map { |r| [r['id'].to_i, r['score'].to_f] }.to_h
result = User.exec_sql(sql)
rval = result.map { |r| [r['id'].to_i, r['score'].to_f] }.to_h
result.clear
rval
end
end