[#73761] Global search: Find work packages by their identifier#22732
[#73761] Global search: Find work packages by their identifier#22732judithroth wants to merge 1 commit intodevfrom
Conversation
There was a problem hiding this comment.
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.identifierto the OR conditions generated byQueries::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. |
| parts.map do |part| | ||
| conditions = [subject_condition(part), | ||
| project_name_condition(part), | ||
| work_package_identifier_condition(part), | ||
| type_name_condition(part), | ||
| status_condition(part)] | ||
|
|
There was a problem hiding this comment.
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.
| parts.map do |part| | ||
| conditions = [subject_condition(part), | ||
| project_name_condition(part), | ||
| work_package_identifier_condition(part), | ||
| type_name_condition(part), | ||
| status_condition(part)] |
There was a problem hiding this comment.
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).
| 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 |
There was a problem hiding this comment.
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).
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