Skip to content

[#73761] Global search: Find work packages by their identifier#22732

Open
judithroth wants to merge 1 commit intodevfrom
feature/73761-global-search-find-work-packages-by-their-identifier
Open

[#73761] Global search: Find work packages by their identifier#22732
judithroth wants to merge 1 commit intodevfrom
feature/73761-global-search-find-work-packages-by-their-identifier

Conversation

@judithroth
Copy link
Copy Markdown
Contributor

https://community.openproject.org/wp/73761

What are you trying to accomplish?

Allow to find work packages by their semantic identifier in the global search

Merge checklist

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

Copilot AI review requested due to automatic review settings April 13, 2026 10:51
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

Extends the work package typeahead/global search filter so users can find work packages by their semantic identifier (e.g., PROJ-42) in addition to the existing subject/project/type/status matching.

Changes:

  • Add work_packages.identifier to the OR conditions generated by Queries::WorkPackages::Filter::TypeaheadFilter.
  • Extend the filter spec with cases that search by identifier (including lowercase input).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
app/models/queries/work_packages/filter/typeahead_filter.rb Adds identifier matching to the typeahead WHERE clause.
spec/models/queries/work_packages/filter/typeahead_filter_spec.rb Adds specs covering identifier-based search behavior.

Comment on lines 44 to 50
parts.map do |part|
conditions = [subject_condition(part),
project_name_condition(part),
work_package_identifier_condition(part),
type_name_condition(part),
status_condition(part)]

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

work_package_identifier_condition uses the generic Contains operator, which generates an ILIKE '%…%' predicate. For semantic identifiers this likely disables the (unique) btree index on work_packages.identifier and can make global search by identifier slower than necessary on large instances. Consider adding a fast-path for identifier-shaped tokens (e.g., LOWER(work_packages.identifier) = LOWER(?) or a prefix match without a leading wildcard) and only falling back to ILIKE '%…%' for partial identifier searches.

Copilot uses AI. Check for mistakes.
Comment on lines 44 to 49
parts.map do |part|
conditions = [subject_condition(part),
project_name_condition(part),
work_package_identifier_condition(part),
type_name_condition(part),
status_condition(part)]
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

Semantic work package identifiers are designed to keep historical identifiers working (see WorkPackage::SemanticIdentifier which falls back to work_package_semantic_aliases). This filter currently only searches work_packages.identifier, so searching for a retired identifier (after a project rename/move) will not find the work package even though the identifier is still resolvable elsewhere. Consider also searching work_package_semantic_aliases.identifier (and ensure the relation stays DISTINCT to avoid duplicates when a work package has multiple aliases).

Copilot uses AI. Check for mistakes.
Comment on lines 56 to 79
shared_let(:epic_work_package) do
create(:work_package,
project:,
type: epic_type,
status: open_status,
subject: "Gorilla work package ething")
subject: "Gorilla work package ething",
identifier: "PHX-1")
end
shared_let(:bug_work_package) do
create(:work_package,
project:,
type: bug_type,
status: open_status,
subject: "Gorilla work package bthing")
subject: "Gorilla work package bthing",
identifier: "PHX-2")
end
shared_let(:task_work_package) do
create(:work_package,
project:,
type: task_type,
status: open_status,
subject: "Work package tthing")
subject: "Work package tthing",
identifier: "PHX-3")
end
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

These examples set identifier: directly on WorkPackage while the default setting is work_packages_identifier = classic (and in semantic mode the after_create callback would allocate/overwrite identifier). As a result, the new behavior isn’t exercised under the real configuration where semantic identifiers are generated automatically. Consider running these identifier search examples under with_settings: { work_packages_identifier: "semantic" } and asserting against the generated identifiers (and/or adding a case for historical aliases if supported).

Copilot uses AI. Check for mistakes.
@judithroth judithroth self-assigned this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants