fix(champs): use approximate count in the task

This commit is contained in:
Paul Chavard 2024-03-18 17:06:24 +01:00
parent a60bc5d630
commit 750b38bbf4

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