OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#44217] Time an costs: Project filter set to "is not (includes subprojects)" not working as expected
Dmitrii006d8f5a907b
diff --git a/modules/reporting/app/models/cost_query/operator.rb b/modules/reporting/app/models/cost_query/operator.rbindex 4333a808b80..e38a04cb34b 100644--- a/modules/reporting/app/models/cost_query/operator.rb+++ b/modules/reporting/app/models/cost_query/operator.rb@@ -50,7 +50,7 @@ class CostQuery::Operator < Report::Operatordef modify(query, field, *values)p_ids = []values.each do |value|- p_ids += ([value] << Project.find(value).descendants.map { |p| p.id })+ p_ids += ([value] << Project.find(value).descendants.map(&:id))end"=".to_operator.modify query, field, p_idsrescue ActiveRecord::RecordNotFound@@ -62,7 +62,9 @@ class CostQuery::Operator < Report::Operatordef modify(query, field, *values)p_ids = []values.each do |value|- p_ids += ([value] << Project.find(value).descendants.map { |p| p.id })+ value.to_s.split(',').each do |id|+ p_ids += ([id] << Project.find(id).descendants.map(&:id))+ endend"!".to_operator.modify query, field, p_idsrescue ActiveRecord::RecordNotFounddiff --git a/modules/reporting/spec/models/cost_query/operator_spec.rb b/modules/reporting/spec/models/cost_query/operator_spec.rbindex 50547e319b7..2024d8ed102 100644--- a/modules/reporting/spec/models/cost_query/operator_spec.rb+++ b/modules/reporting/spec/models/cost_query/operator_spec.rb@@ -236,6 +236,19 @@ describe CostQuery, type: :model, reporting_query_helper: true doexpect(cost_query('projects', 'id', '!_child_projects', project1.id, project2.id).size).to eq(2)end+ it "does !_child_projects on multiple projects as a string" do+ expect(cost_query('projects', 'id', '!_child_projects', "#{project1.id}, #{project2.id}").size).to eq(0)+ p1_c1 = create_project parent: project1+ p2_c1 = create_project parent: project2+ create_project+ expect(cost_query('projects', 'id', '!_child_projects', "#{project1.id}, #{project2.id}").size).to eq(1)+ p1_c1_c1 = create_project parent: p1_c1+ create_project parent: p1_c1_c1+ create_project parent: p2_c1+ create_project+ expect(cost_query('projects', 'id', '!_child_projects', "#{project1.id}, #{project2.id}").size).to eq(2)+ end+it "does =n" do# we have a time_entry with costs==4.2 and a cost_entry with costs==2.3 in our fixturesexpect(query_on_entries('costs', '=n', 4.2).size).to eq(Entry.all.select { |e| e.costs == 4.2 }.count)