diff --git a/app/jobs/scheduled/grant_anniversary_badges.rb b/app/jobs/scheduled/grant_anniversary_badges.rb index 6d0e24bd12d..65eb67423c6 100644 --- a/app/jobs/scheduled/grant_anniversary_badges.rb +++ b/app/jobs/scheduled/grant_anniversary_badges.rb @@ -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) diff --git a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb index 5a2803b7206..097c3cd99f4 100644 --- a/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb +++ b/app/jobs/scheduled/grant_new_user_of_the_month_badges.rb @@ -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