Merge pull request #10140 from tchak/fix-count-in-mentenance-task

fix(champs): use approximate count in the task
This commit is contained in:
Paul Chavard 2024-03-18 17:09:12 +00:00 committed by GitHub
commit a9166c8d8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,11 +3,16 @@
module Maintenance
class FillChampsStableIdTask < MaintenanceTasks::Task
def collection
Champ.includes(:type_de_champ)
Champ.where(stable_id: nil).includes(:type_de_champ)
end
def process(champ)
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
end
def count
sql = "SELECT reltuples FROM pg_class WHERE relname = 'champs';"
Champ.connection.select_value(sql).to_i
end
end
end