Sha256: 9f618831ea8fc3170ef866b587a5e1d800b919eaeddf508ce99406bb81f48cf3

Contents?: true

Size: 774 Bytes

Versions: 66

Compression:

Stored size: 774 Bytes

Contents

module Scrivito
class ObjSearchEnumerator
  class QueryExecutor
    def initialize(workspace)
      @workspace = workspace
    end

    def call(query, continuation=nil, fetched_ids=[])
      query['continuation'] = continuation if continuation
      response = CmsBackend.search_objs(workspace, query)

      ObjSearchEnumerator::Batch.new(
        build_objs(response),
        response['total'].to_i,
        response['continuation'],
        response['facets'],
        fetched_ids
      )
    end

    private

    attr_reader :workspace

    def build_objs(response)
      obj_ids = response['results'].map { |result| result['id'] }
      if obj_ids.present?
        workspace.objs.find_including_deleted(obj_ids)
      else
        []
      end
    end
  end
end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
scrivito_sdk-1.3.0.rc2 lib/scrivito/obj_search_enumerator/query_executor.rb
scrivito_sdk-1.3.0.rc1 lib/scrivito/obj_search_enumerator/query_executor.rb
scrivito_sdk-1.2.0 lib/scrivito/obj_search_enumerator/query_executor.rb
scrivito_sdk-1.2.0.rc3 lib/scrivito/obj_search_enumerator/query_executor.rb
scrivito_sdk-1.2.0.rc2 lib/scrivito/obj_search_enumerator/query_executor.rb
scrivito_sdk-1.2.0.rc1 lib/scrivito/obj_search_enumerator/query_executor.rb