[ARVADOS] updated: 8c9fa09deea0cb68b68f110fdbb1b1daa50a618c

git at public.curoverse.com git at public.curoverse.com
Wed Jun 4 11:16:40 EDT 2014


Summary of changes:
 .../app/controllers/application_controller.rb      | 80 +++++++++++++++++++---
 apps/workbench/app/views/users/_tables.html.erb    | 34 +++++----
 sdk/cli/bin/crunch-job                             | 31 +++++++--
 services/keep/src/keep/keep.go                     | 53 ++++----------
 services/keep/src/keep/volume_unix.go              | 14 +---
 5 files changed, 131 insertions(+), 81 deletions(-)

       via  8c9fa09deea0cb68b68f110fdbb1b1daa50a618c (commit)
       via  161478d5be79e83f3e200b46f0d8d003caa2ffe0 (commit)
       via  70dd308c6d20951745d9b8e849131d0b14e7386a (commit)
       via  a4378cd48648a9ca315713535f651d1bbace322f (commit)
      from  ec08a1b9aefcd801d1f0c0b282b268cbee6939bc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 8c9fa09deea0cb68b68f110fdbb1b1daa50a618c
Merge: 161478d 70dd308
Author: radhika <radhika at curoverse.com>
Date:   Wed Jun 4 11:16:30 2014 -0400

    Merge branch 'master' into 2871-preload-objects


commit 161478d5be79e83f3e200b46f0d8d003caa2ffe0
Author: radhika <radhika at curoverse.com>
Date:   Wed Jun 4 11:15:24 2014 -0400

    2871: add preload methods for collections and logs in application_controller. Use the preload methods in dashboard.

diff --git a/apps/workbench/app/controllers/application_controller.rb b/apps/workbench/app/controllers/application_controller.rb
index a559b01..df41884 100644
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@ -453,7 +453,7 @@ class ApplicationController < ActionController::Base
   helper_method :links_for_object
   def links_for_object object_or_uuid
     uuid = object_or_uuid.is_a?(String) ? object_or_uuid : object_or_uuid.uuid
-    preload_links_for_objects([uuid])
+    preload_links_for_objects([object_or_uuid])
     @all_links_for[uuid]
   end
 
@@ -479,19 +479,81 @@ class ApplicationController < ActionController::Base
   # this can be used to replace any uses of: "dataclass.limit(n)"
   helper_method :get_objects_of_type
   def get_objects_of_type dataclass, size
-    # if the objects_map has a value for this dataclass, and the size used
+    # if the objects_map_for has a value for this dataclass, and the size used
     # to retrieve those objects is greater than equal to size, return it
     size_key = "#{dataclass}_size"
-    if @objects_map && @objects_map[dataclass] && @objects_map[size_key] &&
-        (@objects_map[size_key] >= size)
-      return @objects_map[dataclass] 
+    if @objects_map_for && @objects_map_for[dataclass] && @objects_map_for[size_key] &&
+        (@objects_map_for[size_key] >= size)
+      return @objects_map_for[dataclass] 
     end
 
-    @objects_map = {}
-    @objects_map[dataclass] = dataclass.limit(size)
-    @objects_map[size_key] = size
+    @objects_map_for = {}
+    @objects_map_for[dataclass] = dataclass.limit(size)
+    @objects_map_for[size_key] = size
 
-    return @objects_map[dataclass]
+    return @objects_map_for[dataclass]
+  end
+
+  # helper method to get collection for the given uuid
+  helper_method :get_collection
+  def get_collection uuid
+    preload_collections([uuid])
+    (@all_collections_for[uuid] && @all_collections_for[uuid].first) ?
+          [@all_collections_for[uuid].first] : []
+  end
+
+  # helper method to preload collections for the given uuids
+  helper_method :preload_collections
+  def preload_collections uuids
+    @all_collections_for ||= {}
+    if not uuids.select { |x| @all_collections_for[x].nil? }.any?
+      # already preloaded for all of these uuids
+      return
+    end
+
+    uuids.each do |x|
+      @all_collections_for[x] = []
+    end
+
+    # TODO: make sure we get every page of results from API server
+    Collection.where(uuid: uuids).each do |collection|
+      @all_collections_for[collection.uuid] << collection
+    end
+  end
+
+  # helper method to get log collection for the given log
+  helper_method :get_log_collection
+  def get_log_collection log
+    fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(log)
+    uuid = fixup[1]
+    preload_log_collections([uuid])
+    (@all_log_collections_for[uuid] && @all_log_collections_for[uuid].first) ?
+          [@all_log_collections_for[uuid].first] : []
+  end
+
+  # helper method to preload collections for the given uuids
+  helper_method :preload_log_collections
+  def preload_log_collections logs
+    uuids = []
+    logs.each do |log|
+      fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(log)
+      uuids << fixup[1]
+    end
+
+    @all_log_collections_for ||= {}
+    if not uuids.select { |x| @all_log_collections_for[x].nil? }.any?
+      # already preloaded for all of these uuids
+      return
+    end
+
+    uuids.each do |x|
+      @all_log_collections_for[x] = []
+    end
+
+    # TODO: make sure we get every page of results from API server
+    Collection.limit(100).where(uuid: uuids).each do |collection|
+      @all_log_collections_for[collection.uuid] << collection
+    end
   end
 
 end
diff --git a/apps/workbench/app/views/users/_tables.html.erb b/apps/workbench/app/views/users/_tables.html.erb
index 13cc673..c271f2b 100644
--- a/apps/workbench/app/views/users/_tables.html.erb
+++ b/apps/workbench/app/views/users/_tables.html.erb
@@ -25,6 +25,17 @@
           <th>Progress</th>
         </tr>
 
+        <% 
+          job_outputs = []
+          job_logs = []
+          @my_jobs[0..6].each do |j|
+            job_outputs << j.output
+            job_logs << j.log
+          end
+
+          preload_collections job_outputs
+          preload_log_collections job_logs
+        %>
         <% @my_jobs[0..6].each do |j| %>
           <tr data-object-uuid="<%= j.uuid %>">
             <td>
@@ -36,24 +47,21 @@
             <td>
               <small>
                 <% if j.success and j.output %>
-
                   <a href="<%= collection_path(j.output) %>">
-                    <% Collection.limit(1).where(uuid: j.output).each do |c| %>
-                         <% c.files.each do |file| %>
-                      <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
-                    <% end %>
-                <% end %>
-                </a>
-
-        <% end %>
-        </small>
-</td>
+                    <% get_collection(j.output).each do |c| %>
+                      <% c.files.each do |file| %>
+                        <%= file[0] == '.' ? file[1] : "#{file[0]}/#{file[1]}" %>
+                      <% end %>
+                     <% end %>
+                  </a>
+              <% end %>
+            </small>
+          </td>
 
 <td>
   <small>
     <% if j.log %>
-      <% fixup = /([a-f0-9]{32}\+\d+)(\+?.*)/.match(j.log)%>
-      <% Collection.limit(1).where(uuid: fixup[1]).each do |c| %>
+      <% get_log_collection(j.log).each do |c| %>
         <% c.files.each do |file| %>
           <a href="<%= collection_path(j.log) %>/<%= file[1] %>?disposition=inline&size=<%= file[2] %>">Log</a>
         <% end %>

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list