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
Use upsert in QueryOrderApi
Dombi Attilaa4b77c8b5d17
diff --git a/lib/api/v3/queries/order/query_order_api.rb b/lib/api/v3/queries/order/query_order_api.rbindex 335f8ccb781..9525f311a5e 100644--- a/lib/api/v3/queries/order/query_order_api.rb+++ b/lib/api/v3/queries/order/query_order_api.rb@@ -39,19 +39,13 @@ module API@query.ordered_work_packages.where(work_package_id: wp_id).delete_allend- ##- # Upsert with old rails ways, use +UPSERT+ once available.def upsert_order(wp_id, position)record = @query.ordered_work_packages.find_or_initialize_by(work_package_id: wp_id)- if record.persisted?- record.update_column(:position, position)- else- record.position = position- record.save- end+ upsert_attributes = record.attributes.merge(position:).compact+ OrderedWorkPackage.upsert(upsert_attributes)endend