1155 Commits

Author SHA1 Message Date
Tomas Hykel cee98d16bb fix(ui): Numeric ID instead of semantic one on the table of related work packages (WP #74942) 2026-05-27 15:03:40 +02:00
Tomas Hykel 948fa43321 chore: Remove feature flag for project-based work package identifiers 2026-05-25 17:45:06 +02:00
Alexander Brandon Coles 9d4881216b Merge remote-tracking branch 'opf/dev' into HEAD
# Conflicts:
#	frontend/src/assets/sass/backlogs/_master_backlog.sass
#	modules/backlogs/config/locales/crowdin/ru.yml
#	modules/wikis/config/locales/crowdin/ru.yml
#	modules/wikis/config/locales/crowdin/uk.yml
#	modules/wikis/config/locales/crowdin/zh-CN.yml
2026-05-08 10:35:12 +02:00
Oliver Günther 7ae5604869 Merge pull request #23070 from opf/fix/relation-visible-scope
The performance decreased because of a combination of calls that were supposed to increase performance. 

We have a mechanism in place which automatically eager loads models needed in the element representers when a collection of them is rendered. This is to avoid N+1 queries of course. But, if eager loading is  combined with e.g., a LIMIT, which we do because we paginate, rails automatically falls back to issuing two instead of just one SQL statement. Which makes sense as otherwise LEFT JOINS might mess with the result set. 

But Rails does so in a somewhat simple fashion. It uses the first query to get the DISTINCT ids. The second is used to load the values (without a limit). But instead of removing all WHERE statements in the second SQL statement and then apply just the one for the ids, it keeps the original WHERE statement and applies the one for the ids on top. The problem with that is that the database trips on that (I didn't check the why) and uses a less than optimal query plan. 

That was the problem here as well. The first query remained reasonable quick (300ms) but the second one took 25s. 

The fix is to split the two statements by hand in the representer whenever eager loading is defined. The first query has all the filters but no eager loading and fetches the ids. The second takes the ids, and with eager loading included loads the data. Et voila, second query takes 10ms.   

That at least works for relations, work_packages and projects. But there are other representers that also seem to have custom behaviour. I'm looking into whether they can be easily adapted.
2026-05-07 15:44:13 +02:00
Kabiru Mwenja 0d79f5358c Bust WP representer JSON cache when identifier mode flips (#22960)
Include identifier mode in WP representer cache key
2026-04-28 14:22:56 +03:00
Kabiru Mwenja b8471484e0 Include identifier in Hierarchy eager loader's children SELECT
The ancestors/children representer change calls `child.display_id`,
which consults `identifier` in semantic mode. The Hierarchy eager
loader preloads children with a minimal `SELECT id, subject, project_id,
parent_id` for performance, so `identifier` was missing and
`ActiveModel::MissingAttributeError` fired the moment a query endpoint
rendered a work package with visible children in semantic mode.

Add `identifier` to the SELECT. It's one extra short text column per
child row.
2026-04-22 08:50:32 +03:00
Kabiru Mwenja 3e0f738c2c Expose displayId on work package ancestor and children HAL links
In semantic mode, the work package breadcrumb renders numeric IDs
instead of the semantic identifier because ancestor HAL resources are
built from `_links.ancestors[]` entries that only carry `href` and
`title`. With no top-level `displayId` in `$source`, the frontend getter
falls through to the numeric id parsed from the href.

Emit `displayId` alongside `href`/`title` on each ancestor and child
link in the representer, and have the `displayId` getter fall back to
the self link's `displayId` so resources built from a link payload
alone still surface the semantic identifier.
2026-04-22 08:18:54 +03:00
Kabiru Mwenja 234a870060 Merge pull request #22704 from opf/feature/73716-adapt-work-package-show-view-for-project-based-semantic-work-package-identifiers
Adapt work package show view for semantic identifiers
2026-04-21 13:52:23 +03:00
Kabiru Mwenja 79d4e67a0d Merge pull request #22718 from opf/feature/73756-adapt-routes-for-project-based-semantic-work-package-identifiers
Make find/exists? resolve semantic work package identifiers
2026-04-21 13:13:54 +03:00
Alexander Brandon Coles 7b3b6bdbf3 Clean up remaining Backlogs dead code
Restore the minimal admin settings blankslate so the admin menu route
remains valid after the sprint-based cleanup. Remove the remaining
settings-driven story/task classification code, dead models and
services, and the obsolete filter and spec setup that depended on it.
2026-04-17 10:14:14 +01:00
Kabiru Mwenja 6c02cd1fea Separate displayId from wp.id to fix cascading bugs
Overriding wp.id to return the semantic identifier (e.g. "PROJ-42")
broke cache keys, API filters, row rendering, and CSS selectors that
all depend on the numeric PK.

Instead, keep wp.id as the numeric PK and add two new properties:
- displayId: returns the user-facing identifier ("PROJ-42" or "123")
- displayIdWithHash: returns "#PROJ-42" or "#123" for UI display

Also adds a COALESCE fallback in the SQL representer so work packages
created before semantic mode was enabled still get a valid displayId.
2026-04-15 18:59:42 +03:00
Kabiru Mwenja 8d13c2ac93 Fix grammar in multi-argument error and clarify API route param
- "find are not yet supported" → "find is not yet supported"
- Add semantic identifier example to API route param description
2026-04-15 16:42:18 +03:00
Kabiru Mwenja 63e9854836 Make find/exists? resolve semantic work package identifiers
Extract FinderMethods module that transparently resolves both numeric and
semantic identifiers (e.g. "PROJ-42") using FriendlyId's Object#friendly_id?
for dispatch. The module is included in both the WorkPackage class and
extended onto every relation, so scoped queries like
WorkPackage.visible(user).find("PROJ-42") work seamlessly.

- Override find to resolve semantic IDs via identifier column + alias table
- Override exists? with the same resolution chain
- Refactor find_by_id_or_identifier to use friendly_id? instead of semantic_id?
- Update API route to accept string IDs (type: Integer → type: String)
- Update controller and ViewComponent finders to use find_by_id_or_identifier
- Pass display_id from Rails views to Angular custom elements
2026-04-14 17:38:12 +03:00
Kabiru Mwenja 5bbc4e7563 Rename semanticId to displayId, make always present
Replace the conditional `semanticId` API field with `displayId` which is
always present in work package responses. In semantic mode it returns the
project-based identifier (e.g. "PROJ-42"), in classic mode it returns the
numeric ID as a string. This gives API consumers (frontend, mobile) a
single field to read without conditional logic.

- Add `WorkPackage#display_id` method that encapsulates the mode check
- Update both representers (JSON and SQL) to render `displayId` unconditionally
- Update OpenAPI schema documentation
2026-04-13 14:04:39 +03:00
Kabiru Mwenja d39b720e6e Expose semanticId in API v3 work package endpoints
Adds the computed semanticId property to the HAL representer,
SQL collection representer, and schema representer. The property is
gated behind the semantic_work_package_ids feature flag and returns the
value from WorkPackage#identifier. Includes OpenAPI docs
and the translation key for the schema name.
2026-04-13 14:04:38 +03:00
Oliver Günther 40bc3c04e5 Add OpenProject::Cache.fetch_request_cached for hot-path caching
Add fetch_request_cached method that layers RequestStore in front of Rails.cache.fetch

Used in the following places, as they are repeatedly accessed during schema initialization.

all_work_package_form_attributes, form_config_attribute_representation, Query.available_columns

In my tests, this improves cold cache access by reducing initial number of queries to access cache
2026-04-09 15:48:40 +02:00
Jan Sandbrink f9d8bc6614 Introduce SubclassResponsibility error
This error is intended for cases when a method is
intentionally not implemented, because the module/class defining
it expects a subclass (or class including the module) to implement
the method.

This is intended to distinguish it from other cases, such as:
* feature not implemented yet
* edge case of a method call not yet supported

Notably it avoids the misuse of the Ruby-defined NotImplementedError,
which is only intended for much more specific scenarios:

> Raised when a feature is not implemented on the current platform. For example, methods depending on the fsync or fork system calls may raise this exception [...]

Also see https://docs.ruby-lang.org/en/master/NotImplementedError.html
2026-03-27 08:14:56 +01:00
ulferts 1240b066c3 work package creation and update including backlogs properties 2026-03-11 13:24:32 +01:00
Dombi Attila 60e747be2b Apply manage_sprint_items permissions on the work packages model and update specs.
- Do not remove the assign_versions permission anymore, it still has
purpose in the context of updating work packages.
- Update backlog related specs.
2026-03-03 15:40:36 +02:00
Klaus Zanders ca5e934da9 Merge branch 'dev' into more-visible-scopes 2026-02-10 13:27:01 +01:00
Jens Ulferts 1250412525 Merge pull request #21856 from opf/bug/59360-unexplicable-the-changes-were-retracted-journal-entries-automatic-subjects
Bug/59360 inexplicable the changes were retracted journal entries automatic subjects
2026-02-10 09:19:19 +01:00
Klaus Zanders c2bc836ea1 Consistently load work packages via visible scope 2026-02-09 15:07:49 +01:00
Klaus Zanders c212df5b81 Use more visible scoping for users 2026-02-09 15:07:45 +01:00
ulferts a1032a55a2 move placeholder functionality to backend schema 2026-02-05 17:04:08 +01:00
Jan Sandbrink 5ab26e3b41 Add search_work_packages MCP tool 2026-02-03 16:06:33 +01:00
ulferts 53273d5fdf always generate subject unless overridden - no placeholder text set 2026-02-03 12:09:22 +01:00
ulferts 0bcaa0f175 move automatic subject creation to SetAttributesService
This avoids having to reset the subject first and having to save the automatic subject in an after_perform.
This is especially useful if no change is performed at all. Without the change, even without a change saving would lead to a new journal
2026-02-02 18:03:44 +01:00
Jan Sandbrink f48e390bda Do not render nil titles for projectPhaseDefinition
This is against the schema for definition for links, which
already allow the title to be missing, but don't allow
it to be null. If it's present it must have a string as a value.
2026-01-20 15:22:39 +01:00
Jan Sandbrink 0728d07ad1 Self-test basic schema compliance for a few API models
Those self-tests are "basic" in the sense that they only validate
their compliance with our documented schema in one representation.

These test cases don't yet cover/validate whether the generated
representation also fulfills the schema under different circumstances,
for example when rendering for a user with fewer privileges, not allowed
to see certain fields.

Where necessary, the schema was changed to reflect the reality, e.g.
when those tests revealed that a "required" field might be missing due to
a lack of permissions.

In a few cases the implementation was adapted to allow for stricter guarantees
of the specified schema, for example links allowed to leave out the title key
already, so its not necessary to emit `title: nil` in cases where a title is
not known.
2025-12-15 11:10:34 +01:00
ulferts 7653fbf66b workspace references in representers and auxilliary endpoints 2025-11-25 16:47:59 +01:00
Jan Sandbrink a82257ac66 Automatically pre- and eager-load collections
Index endpoints will automatically discover and use
the `to_eager_load` and `to_preload` declarations of their
representers. This takes away the possibility of forgetting
to add those to the scope.

I found a few endpoint that didn't use them, when other endpoints
rendering the same collection did.

Interestingly the SCM integration modules consistently declared
those methods but never used them.
2025-11-10 16:16:05 +01:00
ulferts edf3c709e3 Merge remote-tracking branch 'origin/dev' into feature/63550-allow-editing-of-individual-work-package-project-attributes-even-if-certain-other-attributes-are-invalid-eg-required-field-empty 2025-10-22 18:17:40 +02:00
Dombi Attila 78a8278895 Move validateCustomFields to be a meta attribute in the api payload. 2025-10-22 18:39:50 +03:00
Jan Sandbrink ebaccce6eb Select columns specifically needed for WP autocompletion
This allows to make more efficient database queries in the API
and reduces overhead by too large JSON responses.

Assuming we fix #68457, additional improvements in response time
can be expected, because we do not need to perform a count for all
matching work packages anymore (because we do not select "total").
2025-10-20 16:45:38 +02:00
Dombi Attila 7cfd71f79e Add validate custom fields flag for the work packages api to allow explicit validation too 2025-10-14 12:01:58 +02:00
Dombi Attila 27ce813500 Introduce EditFormWorkPackageChangeset to enforce custom field validation when editing work packages in angular. 2025-10-14 12:01:58 +02:00
Dombi Attila 0b75d47bdb Fix specs, activate all cusotm fields validations on the work packages update api endpoint. 2025-10-14 12:01:58 +02:00
Klaus Zanders 5ee9642795 Use the correct filter for linking to time entries 2025-08-14 15:15:10 +02:00
Dombi Attila 0e66e4b0f5 [#65513] Form configuration page is broken on the work packages page
https://community.openproject.org/work_packages/65513
2025-07-04 12:56:21 +03:00
Kabiru Mwenja b52debb70d Style/ItBlockParameter: Use it block parameter.RuboCopStyle/ItBlockParameter (#19318) 2025-06-26 13:36:49 +03:00
Ivan Kuchin bf556f4f30 remove stages_and_gates usage from production code 2025-06-20 12:34:59 +02:00
Ivan Kuchin caa9bd5ff2 fix memoization for methods in WorkPackageRepresenter
Maybe using memoist, as we don't seem to have any alternative used in
codebase
2025-06-19 19:38:37 +02:00
Jens Ulferts caa0df2f0c Merge pull request #18851 from opf/implementation/62982-project-phase-column-on-work-package-list
Implementation/62982 project phase column on work package list
2025-06-04 15:49:49 +02:00
Kabiru Mwenja 8f148c3af9 Merge pull request #19063 from opf/feature/59473-set-reminders-api
Feature/59473 Extend Reminders API V3 to include create, update & delete operations
2025-06-04 10:04:52 +03:00
Tobias Dillmann b452e44982 [#62982] group correctly by phase definition 2025-06-03 17:46:40 +02:00
Tobias Dillmann b3c872f546 exclude inactive phases from group by 2025-06-03 17:46:39 +02:00
Tobias Dillmann c0bfa0bfb4 refactor hack for displaying the correct group name 2025-06-03 17:46:34 +02:00
Tobias Dillmann 8e62fd5b4b display project phase in work package table
make group by for project phase definitions work

group by with leading phase icon

undo unnecessary changes
2025-06-03 17:46:33 +02:00
Kabiru Mwenja 1b336f34a6 Add GET /api/v3/reminders endpoint (#19083)
An endpoint that lists all reminders for a user, regardless of the workpackage.
2025-06-03 18:13:36 +03:00
Jens Ulferts 26b33f7657 Merge pull request #18848 from opf/implementation/63015-pdf-xls-cvs-exports-of-linked-phases-for-work-packages
Implementation/63015 pdf xls cvs exports of linked phases for work packages
2025-06-02 14:43:23 +02:00