end
def index
- @links = Link.eager.where(head_kind: 'orvos#collection') |
- Link.eager.where(tail_kind: 'orvos#collection')
+ @links = Link.eager.limit(1000).where(head_kind: 'orvos#collection') |
+ Link.eager.limit(1000).where(tail_kind: 'orvos#collection')
@collections = {}
+ Collection.limit(1000).where({}).each do |c|
+ @collections[c.uuid] = {uuid: c.uuid}
+ end
@links.each do |l|
if l.head_kind == 'orvos#collection'
c = (@collections[l.head_uuid] ||= {uuid: l.head_uuid})
def self.where(*args)
OrvosResourceList.new(self).where(*args)
end
+ def self.limit(*args)
+ OrvosResourceList.new(self).limit(*args)
+ end
def self.eager(*args)
OrvosResourceList.new(self).eager(*args)
end
self
end
+ def limit(max_results)
+ @limit = max_results
+ self
+ end
+
def where(cond)
cond = cond.dup
cond.keys.each do |uuid_key|
cond = cond.merge({ kind_key => 'orvos#' + $orvos_api_client.class_kind(cond[kind_key]) })
end
end
- res = $orvos_api_client.api @resource_class, '', {
+ api_params = {
_method: 'GET',
- where: cond,
- eager: (@eager ? '1' : '0')
+ where: cond
}
+ api_params[:eager] = '1' if @eager
+ api_params[:limit] = @limit if @limit
+ res = $orvos_api_client.api @resource_class, '', api_params
@results = $orvos_api_client.unpack_api_response res
end