class NormalizeHeadlines
def call
Member.select(:id, :headline).find_each do |m|
normalized = m.headline.to_s.strip.gsub(/ +/, ' ')
next if normalized == m.headline
Member.where(id: m.id).update_all(headline: normalized, updated_at: Time.current)
end
end
end
Avoid writing rows when nothing changed—especially in batch jobs. Check changed? or compute the would-be update and skip if identical. This reduces bloat and autovacuum pressure.