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
combine flag for self and descendants manually_scheduled
ulferts14f8165c29e0
diff --git a/app/models/work_packages/scopes/for_scheduling.rb b/app/models/work_packages/scopes/for_scheduling.rbindex 2ff90c42da3..d4b8fce95b0 100644--- a/app/models/work_packages/scopes/for_scheduling.rb+++ b/app/models/work_packages/scopes/for_scheduling.rb@@ -83,10 +83,9 @@ module WorkPackages::Scopes#{paths_sql(work_packages)}SELECT id- FROM clean_paths+ FROM to_scheduleWHERE- NOT clean_paths.manually- AND NOT clean_paths.descendants_manually+ NOT to_schedule.manuallySQLWorkPackage@@ -105,7 +104,6 @@ module WorkPackages::Scopes# The CTE starts from the provided work package and for that returns:# * the id of the work package# * the information, that the starting work package is not manually scheduled.- # * the information, that the starting work package's descendants are not manually scheduled.# Whether the starting work package is manually scheduled or in fact automatically scheduled does make no# difference but we need those four columns later on.#@@ -113,39 +111,38 @@ module WorkPackages::Scopes# packages by a hierarchy (up or down) or follows relationship (only successors). For each such work package# the statement returns:# * id of the work package that is currently at the end of a path.- # * the flag indicating whether the added work package is automatically or manually scheduled.- # * the flag indicating whether *all* of the added work package's descendants are automatically or manually scheduled.+ # * the flag indicating whether the added work package is automatically or manually scheduled. This also includes+ # whether *all* of the added work package's descendants are automatically or manually scheduled.## Paths whose ending work package is marked to be manually scheduled are not joined with any more.def paths_sql(work_packages)- values = work_packages.map { |wp| "(#{wp.id}, false, false)" }.join(', ')+ values = work_packages.map { |wp| "(#{wp.id}, false)" }.join(', ')<<~SQL- clean_paths (id, manually, descendants_manually) AS (- SELECT * FROM (VALUES#{values}) AS t(id, manually, descendants_manually)+ to_schedule (id, manually) AS (+ SELECT * FROM (VALUES#{values}) AS t(id, manually)UNIONSELECTCASE- WHEN relations.to_id = clean_paths.id+ WHEN relations.to_id = to_schedule.idTHEN relations.from_idELSE relations.to_idEND id,- work_packages.schedule_manually manually,- COALESCE(descendants.schedule_manually, false) descendants_manually+ (work_packages.schedule_manually OR COALESCE(descendants.schedule_manually, false)) manuallyFROM- clean_paths+ to_scheduleJOINrelations- ON NOT clean_paths.manually AND NOT clean_paths.descendants_manually+ ON NOT to_schedule.manuallyAND (#{relations_condition_sql})AND- ((relations.to_id = clean_paths.id)- OR (relations.from_id = clean_paths.id AND relations.follows = 0))+ ((relations.to_id = to_schedule.id)+ OR (relations.from_id = to_schedule.id AND relations.follows = 0))LEFT JOIN work_packagesON (CASE- WHEN relations.to_id = clean_paths.id+ WHEN relations.to_id = to_schedule.idTHEN relations.from_idELSE relations.to_idEND) = work_packages.id