X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1bcfe8651af341c6e7cd01a19443c7c288efa932..dcb6eaa5012bf1eea607c61209bee18723769c24:/services/api/app/controllers/arvados/v1/groups_controller.rb diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb index 2356f2eece..7a5713a03c 100644 --- a/services/api/app/controllers/arvados/v1/groups_controller.rb +++ b/services/api/app/controllers/arvados/v1/groups_controller.rb @@ -61,16 +61,27 @@ class Arvados::V1::GroupsController < ApplicationController request_orders = @orders.clone @orders = [] - [Group, - Job, PipelineInstance, PipelineTemplate, + request_filters = @filters + + klasses = [Group, + Job, PipelineInstance, PipelineTemplate, ContainerRequest, Workflow, Collection, - Human, Specimen, Trait].each do |klass| + Human, Specimen, Trait] + + table_names = klasses.map(&:table_name) + request_filters.each do |col, op, val| + if col.index('.') && !table_names.include?(col.split('.', 2)[0]) + raise ArgumentError.new("Invalid attribute '#{col}' in filter") + end + end + + klasses.each do |klass| # If the currently requested orders specifically match the # table_name for the current klass, apply that order. # Otherwise, order by recency. request_order = request_orders.andand.find { |r| r =~ /^#{klass.table_name}\./i } || - "created_at desc" + klass.default_orders.join(", ") @select = nil where_conds = {} @@ -81,6 +92,16 @@ class Arvados::V1::GroupsController < ApplicationController where_conds[:group_class] = "project" end + @filters = request_filters.map do |col, op, val| + if !col.index('.') + [col, op, val] + elsif (col = col.split('.', 2))[0] == klass.table_name + [col[1], op, val] + else + nil + end + end.compact + @objects = klass.readable_by(*@read_users). order(request_order).where(where_conds) @limit = limit_all - all_objects.count