- @links = Link.where(head_uuid: @objects.collect(&:uuid))
- @collection_info = {}
- @objects.each do |c|
- @collection_info[c.uuid] = {
- tag_links: [],
- wanted: false,
- wanted_by_me: false,
- provenance: [],
- links: []
- }
- end
- @links.each do |link|
- @collection_info[link.head_uuid] ||= {}
- info = @collection_info[link.head_uuid]
- case link.link_class
- when 'tag'
- info[:tag_links] << link
- when 'resources'
- info[:wanted] = true
- info[:wanted_by_me] ||= link.tail_uuid == current_user.uuid
- when 'provenance'
- info[:provenance] << link.name
+ base_search = base_search.include_trash(true).limit(limit).with_count("none").offset(offset)
+
+ if params[:filters].andand.length.andand > 0
+ tags = Link.filter(params[:filters]).with_count("none")
+ tagged = []
+ if tags.results.length > 0
+ tagged = query_on.include_trash(true).where(uuid: tags.collect(&:head_uuid))
+ end
+ @objects = (tagged | base_search.filter(params[:filters])).uniq(&:uuid)
+ else
+ @objects = base_search.where(is_trashed: true)
+ end
+
+ if @objects.any?
+ owner_uuids = @objects.collect(&:owner_uuid).uniq
+ @owners = {}
+ @not_trashed = {}
+ [Group, User].each do |owner_class|
+ owner_class.filter([["uuid", "in", owner_uuids]]).with_count("none")
+ .include_trash(true).fetch_multiple_pages(false)
+ .each do |owner|
+ @owners[owner.uuid] = owner
+ end
+ end
+ Group.filter([["uuid", "in", owner_uuids]]).with_count("none").select([:uuid]).each do |grp|
+ @not_trashed[grp.uuid] = true
+ end
+ else
+ return