Skip to content

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

Delete dead code

Marcello Rochad02f12f6db8c
diff --git a/app/models/custom_field/order_statements.rb b/app/models/custom_field/order_statements.rb
index 73156a761c9..945e22fa02f 100644
--- a/app/models/custom_field/order_statements.rb
+++ b/app/models/custom_field/order_statements.rb
@@ -178,56 +178,4 @@ module CustomField::OrderStatements
multi_value:
)
end
-
- # Template method for providing correct ordering of hierarchy items as a flat list for grouping
- #
- # In order to have groups correctly build with the structures above, a flat list of items is required like for
- # CustomOptions. CustomOptions naturally have a position field that encodes the ordering:
- #
- # | id | name | position | custom_field_id
- # ----------------------------------------
- # | 12 | foo | 1 | 9
- # | 14 | foo | 2 | 9
- # | 16 | foo | 3 | 9
- #
- # For Hierarchy::Items this is different. They are organised in generations as they resemble a tree structure.
- # The `sort_order` field is used to encode the position in each generation:
- #
- # | id | name | parent_id | sort_order | custom_field_id
- # ------------------------------------------------------
- # | 12 | foo | 1 | 0 | 9
- # | 14 | bar | 12 | 0 | 9
- # | 16 | baz | 2 | 1 | 9
- #
- # The `sort_order` field is not neatly consecutive numbers as for the CustomOption. That make it impossible to collect
- # the correct work packages for each group (see code).
- #
- # To overcome this problem the algorithms of closure_tree can be used. This method implements the same concept of
- # `self_and_descendants_preordered` from closure_tree. It uses the mathematical power operation to compute distinct
- # position values from `sort_order`, the total number of descendants and the maximum depth of the tree
- # (see implementation).
- def hierarchy_position_sql(ancestor_id:, total_descendants:, max_depth:)
- <<-SQL.squish
- SELECT hi.id,
- hi.parent_id,
- SUM((1 + anc.sort_order) * power(#{total_descendants}, #{max_depth + 1} - depths.generations)) AS position,
- hi.label,
- hi.short,
- hi.is_deleted,
- hi.created_at,
- hi.updated_at,
- hi.custom_field_id
- FROM hierarchical_items hi
- INNER JOIN hierarchical_item_hierarchies hih
- ON hi.id = hih.descendant_id
- JOIN hierarchical_item_hierarchies anc_h
- ON anc_h.descendant_id = hih.descendant_id
- JOIN hierarchical_items anc
- ON anc.id = anc_h.ancestor_id
- JOIN hierarchical_item_hierarchies depths
- ON depths.ancestor_id = #{ancestor_id} AND depths.descendant_id = anc.id
- WHERE hih.ancestor_id = #{ancestor_id}
- GROUP BY hi.id
- SQL
- end
end