diff --git a/VERSION b/VERSION index 547c23c55..5c2e2531a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.66 +3.7.67 diff --git a/lib/gooddata/models/metadata/label.rb b/lib/gooddata/models/metadata/label.rb index 2dd9f8e33..2b106bb4b 100644 --- a/lib/gooddata/models/metadata/label.rb +++ b/lib/gooddata/models/metadata/label.rb @@ -44,14 +44,31 @@ def find_element_value(element_id) # In the case filter a specific value, because the API /validElements only filter by partial match, we need to filter again at client side for exact match. # @return [Array] Results def get_valid_elements(*args) + results = {} if args && !args.empty? && args.first[:filter] + # Support paging in case filter by a specific value params = args.first - params[:limit] = 100_000 - results, = valid_elements params - results['validElements']['items'] = results['validElements']['items'].select do |i| - i['element']['title'] == params[:filter] + all_valid_elements = [] + offset = 0 + paging_limit = 10_000 + + loop do + params[:offset] = offset + params[:limit] = paging_limit + results, = valid_elements params + all_valid_elements << results['validElements']['items'].select do |i| + i['element']['title'] == params[:filter] + end + + if results['validElements']['items'].count < paging_limit + results['validElements']['items'] = all_valid_elements + break + else + offset += paging_limit + end end else + # This case will support paging by the method which call this method eg: values(...) method results, = valid_elements(*args) end results diff --git a/lib/gooddata/models/user_filters/user_filter_builder.rb b/lib/gooddata/models/user_filters/user_filter_builder.rb index 029fa6b12..e3b364f20 100644 --- a/lib/gooddata/models/user_filters/user_filter_builder.rb +++ b/lib/gooddata/models/user_filters/user_filter_builder.rb @@ -180,7 +180,8 @@ def self.create_label_cache(result, options = {}) def self.create_lookups_cache(small_labels) small_labels.reduce({}) do |a, e| - lookup = e.values(:limit => 1_000_000).reduce({}) do |a1, e1| + # The validElements API allow maximum paging with 10000 items + lookup = e.values(:limit => 10_000).reduce({}) do |a1, e1| a1[e1[:value]] = e1[:uri] a1 end