Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/59184 order by stages and gates on project list #17530

Draft
wants to merge 9 commits into
base: dev
Choose a base branch
from

Conversation

EinLama
Copy link
Contributor

@EinLama EinLama commented Jan 3, 2025

Ticket

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

What are you trying to accomplish?

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, ...)

def self.key
valid_ids = Project::LifeCycleStepDefinition.pluck(:id)

/\Alcsd_(#{valid_ids.join('|')})\z/

Check warning

Code scanning / Brakeman

Model attribute used in regular expression. Warning

Model attribute used in regular expression.
@EinLama EinLama force-pushed the feature/59184-order-by-stages-and-gates-on-project-list branch from c6e1367 to d9ffe12 Compare January 4, 2025 15:16
@EinLama EinLama force-pushed the feature/59184-order-by-stages-and-gates-on-project-list branch from f551cb5 to 73a8642 Compare January 6, 2025 08:44
Using a named subquery will break as those have to be unique.
The same issue applies to CTEs - they need a unique name per query.
To solve this, I have allowed queries to use CTEs and define their name.
The name will be derived from the definition id, which is unique per
query. Therefore, you can now order by multiple life cycle definitions
at once.
def order(scope)
with_raise_on_invalid do
# Note that a gate does not define an end_date. This code still works.
direction_clause = Arel.sql("#{cte_name}.start_date #{direction}, #{cte_name}.end_date #{direction}")

Check warning

Code scanning / Brakeman

Possible SQL injection. Warning

Possible SQL injection.
# Note that a gate does not define an end_date. This code still works.
direction_clause = Arel.sql("#{cte_name}.start_date #{direction}, #{cte_name}.end_date #{direction}")

scope.where("#{cte_name}.def_id = :def_id OR #{cte_name}.def_id IS NULL", def_id: life_cycle_step_definition.id)

Check notice

Code scanning / Brakeman

Possible SQL injection. Note

Possible SQL injection.
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.

1 participant