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
simplify Version.order_by_semver_name
Ivan Kuchin48d78777ceda
diff --git a/app/models/versions/scopes/order_by_semver_name.rb b/app/models/versions/scopes/order_by_semver_name.rbindex 35545c9e8db..b4affc08d6f 100644--- a/app/models/versions/scopes/order_by_semver_name.rb+++ b/app/models/versions/scopes/order_by_semver_name.rb@@ -32,21 +32,7 @@ module Versions::Scopesclass_methods dodef order_by_semver_name- reorder semver_sql, :name- end-- # Returns an sql for ordering which:- # * Returns a substring from the beginning of the name up until the first alphabetical character e.g. "1.2.3 "- # from "1.2.3 ABC"- # * Replaces all non numerical character groups in that substring by a blank, e.g "1.2.3 " to "1 2 3 "- # * Splits the result into an array of individual number parts, e.g. "{1, 2, 3, ''}" from "1 2 3 "- # * removes all empty array items, e.g. "{1, 2, 3}" from "{1, 2, 3, ''}"- def semver_sql(table_name = Version.table_name)- sql = <<~SQL- array_remove(regexp_split_to_array(regexp_replace(substring(#{table_name}.name from '^[^a-zA-Z]+'), '\\D+', ' ', 'g'), ' '), '')::int[]- SQL-- Arel.sql(sql)+ order :nameendendend