Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dossier): remove legacy row_ids code #11341

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions app/models/concerns/dossier_champs_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,11 @@ def repetition_rows_for_export(type_de_champ)

def repetition_row_ids(type_de_champ)
return [] if !type_de_champ.repetition?
return [] unless stable_id_in_revision?(type_de_champ.stable_id)
@repetition_row_ids ||= {}
@repetition_row_ids[type_de_champ.stable_id] ||= begin
rows = champs_in_revision.filter { _1.row? && _1.stable_id == type_de_champ.stable_id }
row_ids = rows.reject(&:discarded?).map(&:row_id)

# Legacy rows are rows that have been created before the introduction of the discarded_at column
# TODO migrate and clean
children_stable_ids = revision.children_of(type_de_champ).map(&:stable_id)
discarded_row_ids = rows.filter(&:discarded?).map(&:row_id)
legacy_row_ids = champs_in_revision.filter { _1.stable_id.in?(children_stable_ids) && _1.row_id.present? }.map(&:row_id).uniq
row_ids += (legacy_row_ids - discarded_row_ids)
row_ids.uniq.sort
end
@repetition_row_ids[type_de_champ.stable_id] ||= champs_in_revision
.filter { _1.row? && _1.stable_id == type_de_champ.stable_id && !_1.discarded? }
.map(&:row_id)
.sort
end

def repetition_add_row(type_de_champ, updated_by:)
Expand Down
Loading