Skip to content

Fix HourlyRate display in admin area to include only relevant projects - #24697

Merged
klaustopher merged 4 commits into
release/17.7from
fix-op-19843
Aug 13, 2026
Merged

Fix HourlyRate display in admin area to include only relevant projects#24697
klaustopher merged 4 commits into
release/17.7from
fix-op-19843

Conversation

@klaustopher

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/projects/OP/work_packages/OP-19843/activity

What are you trying to accomplish?

  • When the user is not a member of the project and they never had a rate defined for the project, we will not list the project in that view
  • When the user is not a member of the project but they have a rate set up for the project, we list the project but hide the Update button
  • When the user is a member of the project, it is listed there with the Update button.

Screenshots

What approach did you choose and why?

Merge checklist

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

projects_with_costs.each do |project|
rates[project] = rates_by_project.fetch(project, [])
project_rates = rates_by_project.fetch(project, [])
next if project_rates.empty? && usr.projects.exclude?(project)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this cause an N+1 query? usr.projects.exclude?(project) may query the db for each project. The view also checks @user.projects.include?(project). Maybe we could load the user’s projects once and reuse them in both places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

user.projects is loaded once and is then cached, it does 1 extra query, not n+1.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought it might be cached too, but doesn’t include? run an EXISTS query each time when the association hasn’t been loaded yet?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When the association is loaded, it will not issue an EXISTS query. I explicitly added the load statement so that it is ensured that it is preloaded, even though it should already be.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, thanks for explanation.

@klaustopher
klaustopher merged commit ea95a3a into release/17.7 Aug 13, 2026
15 checks passed
@klaustopher
klaustopher deleted the fix-op-19843 branch August 13, 2026 08:25
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

2 participants