Skip to content

[#73373] Background job for migrating pre-existing data to semantic identifiers#22566

Closed
thykel wants to merge 135 commits intodevfrom
poc/71645-convert-to-wp-semantic-ids
Closed

[#73373] Background job for migrating pre-existing data to semantic identifiers#22566
thykel wants to merge 135 commits intodevfrom
poc/71645-convert-to-wp-semantic-ids

Conversation

@thykel
Copy link
Copy Markdown
Contributor

@thykel thykel commented Mar 29, 2026

Ticket

https://community.openproject.org/projects/communicator-stream/work_packages/71645/activity

What are you trying to accomplish?

Add a background procedure to convert project & work package identifiers from classic (project cool_project, WP 1) to semantic (project CP, WP CP-1).

The procedure is invoked by switching to the semantic ("alphanumeric") identifier format via the admin settings.

Screenshots

What approach did you choose and why?

The original noop background job is now replaced by ProjectIdentifiers::ConvertInstanceToSemanticIdsJob. This is the flow:

  1. Click the admin button to switch identifier mode to semantic.
  2. Invoke ProjectIdentifiers::ConvertInstanceToSemanticIdsJob
  3. If the database does not require any identifier transformation (e.g. proj => PROJ), simply set the the identifier mode to semantic and exit with success. Otherwise, continue further.
  4. Spawn a batch of per-project jobs that fix the project identifier & populate work package identifiers (ProjectIdentifiers::BackfillProjectJob)
  5. Once the batch has finished processing, GOTO 1. If this has already happened 10 times, abort the job as we're likely in an infinite loop.

Additionally, tweak the interface of the admin setting controller to have some proper shape -- previously it required presence of settings hash + a separate confirm_dangerous_action param, now it only needs a properly set settings hash.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Copy link
Copy Markdown
Contributor

@judithroth judithroth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is coming along nicely! I'm sorry I found another edge case that keeps me from approving 😅

Comment thread app/workers/project_identifiers/backfill_project_job.rb Outdated
Comment thread app/workers/project_identifiers/backfill_project_job.rb Outdated
Comment thread app/workers/project_identifiers/convert_instance_to_semantic_ids_job.rb Outdated
Comment thread app/models/work_package_semantic_alias.rb
Comment thread app/workers/project_identifiers/convert_instance_to_semantic_ids_job.rb Outdated
Comment thread spec/workers/project_identifiers/backfill_project_job_spec.rb
Comment thread spec/workers/project_identifiers/backfill_project_job_spec.rb Outdated
@thykel thykel requested a review from akabiru April 9, 2026 09:28
Comment thread app/workers/project_identifiers/backfill_project_job.rb Outdated
Comment thread app/services/project_identifiers/backfill_project_service.rb Outdated
Comment thread app/services/project_identifiers/backfill_project_service.rb
Comment thread spec/controllers/admin/settings/work_packages_identifier_controller_spec.rb Outdated
Comment thread app/services/project_identifiers/backfill_project_service.rb Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Comments suppressed due to low confidence (1)

app/models/work_package/semantic_identifier.rb:103

  • The removal of private makes alias_rows_for_sequence_number a public instance method on WorkPackage, which looks like an internal helper used only by allocate_and_register_semantic_id. Consider restoring private (or marking just this method private) to avoid accidentally expanding the public API surface.

  # Builds alias rows for every identifier this project has ever used at the given sequence (including the current one).
  # This also includes "ghost identifiers" -- i.e. those that weren't ever actually generated, but should work
  # as a historical alias (e.g. OLDPROJ-42 should work even if WP #42 was created after rename to NEWPROJ)
  def alias_rows_for_sequence_number(seq)
    project.slugs
           .pluck(:slug)
           .map { |prefix| { identifier: "#{prefix}-#{seq}", work_package_id: id } }
  end

Comment thread spec/workers/project_identifiers/convert_project_to_semantic_ids_job_spec.rb Outdated
Comment thread app/services/project_identifiers/convert_project_to_semantic_service.rb Outdated
Comment thread app/models/projects/semantic_identifier.rb Outdated
Comment thread app/services/project_identifiers/convert_project_to_semantic_service.rb Outdated
Comment thread app/services/project_identifiers/convert_project_to_semantic_service.rb Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@thykel
Copy link
Copy Markdown
Contributor Author

thykel commented Apr 16, 2026

@thykel thykel closed this Apr 16, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants