task(champs): update champs for each dossier
This commit is contained in:
parent
776f81eb0e
commit
bda2d80dea
1 changed files with 8 additions and 10 deletions
|
@ -3,18 +3,16 @@
|
||||||
module Maintenance
|
module Maintenance
|
||||||
class FillChampsStableIdTask < MaintenanceTasks::Task
|
class FillChampsStableIdTask < MaintenanceTasks::Task
|
||||||
def collection
|
def collection
|
||||||
Champ.all
|
Dossier.all
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(champ)
|
def process(dossier)
|
||||||
if !champ.attribute_present?(:stable_id)
|
dossier.champs
|
||||||
|
.includes(:type_de_champ)
|
||||||
|
.where(stable_id: nil)
|
||||||
|
.each do |champ|
|
||||||
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
|
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def count
|
|
||||||
sql = "SELECT reltuples FROM pg_class WHERE relname = 'champs';"
|
|
||||||
Champ.connection.select_value(sql).to_i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue