Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions app/models/concerns/edition/identifiable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def slug_from_title

def set_slug
# Translations return nil from `string_to_slug`, in which case we return early as we should not set the slug based on a translation title
# Corporate information pages also return nil from `string_to_slug`, because their slugs are set based on document type.
return if string_for_slug.nil?

# Generate a default slug using the babosa gem's to_slug and normalize methods
Expand Down
7 changes: 5 additions & 2 deletions db/data_migration/20260414111505_generate_slug_from_title.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
total_processed = 0

Edition.skip_callback(:update, :after, :republish_topical_event_to_publishing_api)
Edition.in_pre_publication_state.find_each(batch_size: 1000) do |edition|
edition.set_slug
total_processed += 1 if edition.save(validate: false)
total_processed += 1 if edition.update_columns(
slug: edition.slug,
slug_from_title: edition.slug_from_title,
touch: false,
)

puts "Processed #{total_processed} editions" if (total_processed % 5000).zero?
end
Expand Down
Loading