Merge pull request #10109 from tchak/refactor-champs-add-stable_id
add stable_id and stream
This commit is contained in:
commit
003e73e853
7 changed files with 37 additions and 8 deletions
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
|
@ -104,7 +104,7 @@ jobs:
|
||||||
|
|
||||||
system_tests:
|
system_tests:
|
||||||
name: System tests
|
name: System tests
|
||||||
runs-on: self-hosted
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
RUBY_YJIT_ENABLE: "1"
|
RUBY_YJIT_ENABLE: "1"
|
||||||
services:
|
services:
|
||||||
|
|
|
@ -221,7 +221,7 @@ class Champ < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def clone(fork = false)
|
def clone(fork = false)
|
||||||
champ_attributes = [:parent_id, :private, :row_id, :type, :type_de_champ_id]
|
champ_attributes = [:parent_id, :private, :row_id, :type, :type_de_champ_id, :stable_id, :stream]
|
||||||
value_attributes = fork || !private? ? [:value, :value_json, :data, :external_id] : []
|
value_attributes = fork || !private? ? [:value, :value_json, :data, :external_id] : []
|
||||||
relationships = fork || !private? ? [:etablissement, :geo_areas] : []
|
relationships = fork || !private? ? [:etablissement, :geo_areas] : []
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,9 @@ class TypeDeChamp < ApplicationRecord
|
||||||
def params_for_champ
|
def params_for_champ
|
||||||
{
|
{
|
||||||
private: private?,
|
private: private?,
|
||||||
type: "Champs::#{type_champ.classify}Champ"
|
type: "Champs::#{type_champ.classify}Champ",
|
||||||
|
stable_id:,
|
||||||
|
stream: 'main'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
13
app/tasks/maintenance/fill_champs_stable_id_task.rb
Normal file
13
app/tasks/maintenance/fill_champs_stable_id_task.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module Maintenance
|
||||||
|
class FillChampsStableIdTask < MaintenanceTasks::Task
|
||||||
|
def collection
|
||||||
|
Champ.includes(:type_de_champ)
|
||||||
|
end
|
||||||
|
|
||||||
|
def process(champ)
|
||||||
|
champ.update_columns(stable_id: champ.stable_id, stream: 'main')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
6
db/migrate/20240316065520_champs_add_stable_id.rb
Normal file
6
db/migrate/20240316065520_champs_add_stable_id.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class ChampsAddStableId < ActiveRecord::Migration[7.0]
|
||||||
|
def change
|
||||||
|
add_column :champs, :stable_id, :bigint
|
||||||
|
add_column :champs, :stream, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2024_02_27_163855) do
|
ActiveRecord::Schema[7.0].define(version: 2024_03_16_065520) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -263,6 +263,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_02_27_163855) do
|
||||||
t.boolean "private", default: false, null: false
|
t.boolean "private", default: false, null: false
|
||||||
t.datetime "rebased_at", precision: nil
|
t.datetime "rebased_at", precision: nil
|
||||||
t.string "row_id"
|
t.string "row_id"
|
||||||
|
t.bigint "stable_id"
|
||||||
|
t.string "stream"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.integer "type_de_champ_id"
|
t.integer "type_de_champ_id"
|
||||||
t.datetime "updated_at", precision: nil
|
t.datetime "updated_at", precision: nil
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
FactoryBot.define do
|
FactoryBot.define do
|
||||||
factory :champ do
|
factory :champ do
|
||||||
|
stream { 'main' }
|
||||||
add_attribute(:private) { false }
|
add_attribute(:private) { false }
|
||||||
|
|
||||||
dossier { association :dossier }
|
dossier { association :dossier }
|
||||||
type_de_champ { association :type_de_champ, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ, procedure: dossier.procedure }
|
||||||
|
|
||||||
|
after(:build) do |champ, _evaluator|
|
||||||
|
champ.stable_id = champ.type_de_champ.stable_id
|
||||||
|
end
|
||||||
|
|
||||||
trait :private do
|
trait :private do
|
||||||
add_attribute(:private) { true }
|
add_attribute(:private) { true }
|
||||||
end
|
end
|
||||||
|
@ -239,11 +244,12 @@ FactoryBot.define do
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_engagement_juridique, class: 'Champs::EngagementJuridiqueChamp' do
|
factory :champ_engagement_juridique, class: 'Champs::EngagementJuridiqueChamp' do
|
||||||
type_de_champ { association :type_de_champ_engagement_juridique, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_engagement_juridique, procedure: dossier.procedure }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_cojo, class: 'Champs::COJOChamp' do
|
factory :champ_cojo, class: 'Champs::COJOChamp' do
|
||||||
type_de_champ { association :type_de_champ_cojo, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_cojo, procedure: dossier.procedure }
|
||||||
end
|
end
|
||||||
|
|
||||||
factory :champ_rnf, class: 'Champs::RNFChamp' do
|
factory :champ_rnf, class: 'Champs::RNFChamp' do
|
||||||
type_de_champ { association :type_de_champ_rnf, procedure: dossier.procedure }
|
type_de_champ { association :type_de_champ_rnf, procedure: dossier.procedure }
|
||||||
|
|
Loading…
Reference in a new issue