2024-03-15 14:56:46 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Maintenance
|
|
|
|
class FillChampsStableIdTask < MaintenanceTasks::Task
|
|
|
|
def collection
|
2024-03-19 14:25:36 +01:00
|
|
|
Champ.all
|
2024-03-15 14:56:46 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def process(champ)
|
2024-03-19 14:25:36 +01:00
|
|
|
if !champ.attribute_present?(:stable_id)
|
|
|
|
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
|
|
|
|
end
|
2024-03-15 14:56:46 +01:00
|
|
|
end
|
2024-03-18 17:06:24 +01:00
|
|
|
|
|
|
|
def count
|
|
|
|
sql = "SELECT reltuples FROM pg_class WHERE relname = 'champs';"
|
|
|
|
Champ.connection.select_value(sql).to_i
|
|
|
|
end
|
2024-03-15 14:56:46 +01:00
|
|
|
end
|
|
|
|
end
|