ff69d89fda423d52b63b70b0ef6bf328d2fdd3d3
[arvados.git] / apps / workbench / app / controllers / work_units_controller.rb
1 class WorkUnitsController < ApplicationController
2   def find_objects_for_index
3     # If it's not the index rows partial display, just return
4     # The /index request will again be invoked to display the
5     # partial at which time, we will be using the objects found.
6     return if !params[:partial]
7
8     @limit = 20
9     @filters = @filters || []
10
11     # get next page of pipeline_instances
12     filters = @filters + [["uuid", "is_a", ["arvados#pipelineInstance"]]]
13     pipelines = PipelineInstance.limit(@limit).order(["created_at desc"]).filter(filters)
14
15     # get next page of jobs
16     filters = @filters + [["uuid", "is_a", ["arvados#job"]]]
17     jobs = Job.limit(@limit).order(["created_at desc"]).filter(filters)
18
19     # get next page of container_requests
20     filters = @filters + [["uuid", "is_a", ["arvados#containerRequest"]]]
21     crs = ContainerRequest.limit(@limit).order(["created_at desc"]).filter(filters)
22     @objects = (jobs.to_a + pipelines.to_a + crs.to_a).sort_by(&:created_at).reverse.first(@limit)
23
24     if @objects.any?
25       @next_page_filters = next_page_filters('<=')
26       @next_page_href = url_for(partial: :all_processes_rows,
27                                 filters: @next_page_filters.to_json)
28       preload_links_for_objects(@objects.to_a)
29     else
30       @next_page_href = nil
31     end
32   end
33
34   def next_page_href with_params={}
35     @next_page_href
36   end
37 end