semver sorting/group_by for wp table

pull/8205/head
ulferts 5 years ago
parent 95fd58cff7
commit 3ed9e45a95
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 2
      app/models/queries/work_packages/columns/property_column.rb
  2. 6
      app/models/query/group_by.rb
  3. 11
      app/models/query/results.rb
  4. 2
      app/models/versions/scopes/order_by_semver_name.rb

@ -97,7 +97,7 @@ class Queries::WorkPackages::Columns::PropertyColumn < Queries::WorkPackages::Co
},
fixed_version: {
association: 'fixed_version',
sortable: %w(start_date effective_date name),
sortable: [->(table_name) { "array_remove(regexp_split_to_array(regexp_replace(substring(#{table_name}.name from '^[^a-zA-Z]+'), '\\D+', ' ', 'g'), ' '), '')::int[]" }, 'name'],
default_order: 'DESC',
null_handling: 'NULLS LAST',
groupable: "#{WorkPackage.table_name}.fixed_version_id"

@ -158,14 +158,16 @@ module ::Query::GroupBy
end
def aliased_group_by_sort_order(alias_name, sortable, order = nil)
column = if alias_name
column = if alias_name && sortable.respond_to?(:call)
sortable.call(alias_name)
elsif alias_name
"#{alias_name}.#{sortable}"
else
sortable
end
if order
column + " #{order}"
column + " #{order} "
else
column
end

@ -28,9 +28,6 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
require_dependency 'query/group_by'
require_dependency 'query/sums'
class ::Query::Results
include ::Query::GroupBy
include ::Query::Sums
@ -154,7 +151,13 @@ class ::Query::Results
aliases = include_aliases
reflection_includes.each do |inc|
sorting_by_column_name[inc.to_s] = Array(sorting_by_column_name[inc.to_s]).map { |column| "#{aliases[inc]}.#{column}" }
sorting_by_column_name[inc.to_s] = Array(sorting_by_column_name[inc.to_s]).map do |column|
if column.respond_to?(:call)
column.call(aliases[inc])
else
"#{aliases[inc]}.#{column}"
end
end
end
sorting_by_column_name

@ -29,7 +29,7 @@
#++
module Versions::Scopes
class OrderBySemverName# < Scopes::Base
class OrderBySemverName
class << self
def fetch
Version.reorder Arel.sql(order_sql)

Loading…
Cancel
Save