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
WIP Add migration for flipping clipping planes that were created in OP (#9446)
Wieland Lindenthal496253d02930
diff --git a/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rb b/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rbnew file mode 100644index 00000000000..329e216801e--- /dev/null+++ b/db/migrate/20210713081724_flip_bcf_viewpoint_clipping_direction_selectively.rb@@ -0,0 +1,43 @@+class FlipBcfViewpointClippingDirectionSelectively < ActiveRecord::Migration[6.1]+ def up+ flip_op_clipping_planes+ end++ def down+ flip_op_clipping_planes+ end++ private++ def flip_op_clipping_planes+ viewpoints = select_viewpoints_created_in_op+ viewpoints.each do |viewpoint|+ new_json_viewpoint = flip_clipping_planes(viewpoint.json_viewpoint)+ viewpoint.update_column(:json_viewpoint, new_json_viewpoint)+ end+ end++ def select_viewpoints_created_in_op+ join_condition = %{+ bcf_viewpoints.json_viewpoint->>'clipping_planes' IS NOT NULL+ AND+ (+ bcf_issues.markup IS NULL+ OR+ XPATH_EXISTS('/comment()[contains(., ''Created by OpenProject'')]', bcf_issues.markup)+ )+ }+ ::Bim::Bcf::Viewpoint.joins(:issue).where(join_condition)+ end++ def flip_clipping_planes(viewpoint)+ viewpoint_dup = viewpoint.deep_dup+ viewpoint_dup["clipping_planes"].each do |plane|+ plane["direction"]["x"] *= -1+ plane["direction"]["y"] *= -1+ plane["direction"]["z"] *= -1+ end++ viewpoint_dup+ end+enddiff --git a/modules/bim/app/models/bim/bcf/viewpoint.rb b/modules/bim/app/models/bim/bcf/viewpoint.rbindex c9dfdd74d9e..aaa3bff718b 100644--- a/modules/bim/app/models/bim/bcf/viewpoint.rb+++ b/modules/bim/app/models/bim/bcf/viewpoint.rb@@ -35,6 +35,10 @@ module Bim::Bcfendend+ def clipping_planes?+ json_viewpoint && json_viewpoint["clipping_planes"]+ end+def snapshot=(file)snapshot&.destroybuild_snapshot file