Repository navigation
[FND-286] Categories - filtering grouping and sorting - #27149
brunopagno wants to merge 5 commits into
Conversation
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
39ba872 to
6794db6
Compare
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
6794db6 to
772caeb
Compare
3f380a1 to
60489b5
Compare
| # Only the single category_id is journaled, so the join table read by | ||
| # `Queries::WorkPackages::Filter::CategoryFilter` is swapped for a stand-in built from it: | ||
| # | ||
| # before: SELECT 1 FROM "work_package_categories" WHERE (work_package_categories.work_package_id = ... | ||
| # after: SELECT 1 FROM (SELECT work_packages.id AS work_package_id, work_packages.category_id | ||
| # WHERE work_packages.category_id IS NOT NULL) "work_package_categories" WHERE ... | ||
| def substitute_work_package_categories_join_in_predicate(predicate) | ||
| return unless predicate.is_a? String | ||
|
|
||
| join_table_source = "FROM \"#{WorkPackageCategory.table_name}\"" | ||
| journaled_category_source = "FROM (#{journaled_work_package_categories_sql}) \"#{WorkPackageCategory.table_name}\"" | ||
|
|
||
| predicate.gsub!(join_table_source, journaled_category_source) | ||
| end | ||
|
|
||
| def journaled_work_package_categories_sql | ||
| <<~SQL.squish | ||
| SELECT #{model.table_name}.id AS work_package_id, #{model.table_name}.category_id | ||
| WHERE #{model.table_name}.category_id IS NOT NULL | ||
| SQL | ||
| end |
There was a problem hiding this comment.
🍊 The stand-in only knows the one mirrored category_id, so at a baseline a work package that had A and B looks like it only had A: = B misses it and ! B includes it.
#27253 adds work_package_category_journals, same shape as the version journals. Shall we land that one first and swap here the way versions do? The stand-in and its comment can then go:
def substitute_work_package_categories_join_in_predicate(predicate)
return unless predicate.is_a? String
category_journals = Journal::WorkPackageCategoryJournal.table_name
work_package_categories = WorkPackageCategory.table_name
models = model.table_name
predicate.gsub! "#{work_package_categories}.work_package_id = #{models}.id",
"#{category_journals}.journal_id = #{models}.journal_id"
predicate.gsub! "\"#{work_package_categories}\"",
"\"#{category_journals}\""
endA baseline example with a two-category work package would pin it down. If this PR goes first instead, the swap can move to #27253.
There was a problem hiding this comment.
I can also take care of this after the fact @brunopagno so all good.
There was a problem hiding this comment.
Yeah, I was hoping to do a "multi version baseline" in a separate step. This was meant to cover only the current state of things. But probably worth a comment on it.
| let!(:beta_wp) { create(:work_package, project:, category_ids_replacements: [beta.id]) } | ||
| let!(:uncategorized_wp) { create(:work_package, project:) } | ||
|
|
||
| describe "filtering" do |
There was a problem hiding this comment.
🍏 Could the flag-on block also cover *, !*, a multi-value = and DESC? With several categories per work package only single-value = and ! are exercised right now.
| describe "#where" do | ||
| let(:values) { ["1"] } | ||
|
|
||
| it "reads the work_package_categories join rows" do | ||
| expect(instance.where).to include("work_package_categories") | ||
| expect(instance.where).not_to include("#{WorkPackage.table_name}.category_id") | ||
| end | ||
| end |
There was a problem hiding this comment.
🍏 This only checks that the SQL mentions a table name, which the integration spec already proves by behavior. Drop it? Same for the two "via the work_package_categories join rows" examples in property_select_spec.rb.
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
Ticket
https://community.openproject.org/projects/TC/work_packages/FND-286/activity
What are you trying to accomplish?
Adjust filtering grouping and sorting for categories as multi values
AI involvement
Collaborative – AI generated a substantial part of the code; I reviewed and understand every line
Merge checklist