[ARVADOS] updated: b3bb4cdff0b10f42624b67ae19c03f1edfcecab0

git at public.curoverse.com git at public.curoverse.com
Mon Feb 15 12:35:14 EST 2016


Summary of changes:
 .../app/controllers/application_controller.rb      | 76 +++++++++++++++++++++-
 .../views/application/_projects_tree_menu.html.erb | 29 ++++++++-
 .../test/controllers/projects_controller_test.rb   | 29 +++++++++
 backports/python-gflags/fpm-info.sh                |  1 +
 sdk/cli/bin/crunch-job                             |  6 +-
 services/keepstore/volume_generic_test.go          | 62 ++++++++++++++++++
 .../crunchstat_summary/summarizer.py               | 50 ++++++++++----
 .../tests/logfile_20151204190335.txt.gz.report     |  2 +
 .../tests/logfile_20151210063411.txt.gz.report     |  2 +
 .../tests/logfile_20151210063439.txt.gz.report     |  2 +
 tools/crunchstat-summary/tests/test_examples.py    |  3 +
 11 files changed, 246 insertions(+), 16 deletions(-)
 create mode 100644 backports/python-gflags/fpm-info.sh

       via  b3bb4cdff0b10f42624b67ae19c03f1edfcecab0 (commit)
       via  0728458bfd4236fbcfe42a59ccd58754de026bb4 (commit)
       via  3920b0d627ac89687a741b186554c1afd61750f5 (commit)
       via  581f5f019db485cec8638c24adb8a78990e10bba (commit)
       via  7f0aacd7c9e055fd245b1c4516e5f7ec24ebf5e2 (commit)
       via  884558f4505049685c7cdb5b50c4b8948f38cd1b (commit)
       via  9c2cc3772d61d0930f28942f778b7ca4b096d717 (commit)
       via  6b98fad744480d42fe084d70429bf3d658a06caa (commit)
       via  2eb7ed57612ce4d360e02b4c3cd0dc43f6db9511 (commit)
       via  42db5188e104e94ce73d743edaafb1c2053e3c0c (commit)
       via  2872b6deb0d9e3d5fbfe0a172aa87949980dfe6f (commit)
       via  292d026aecbc6b7e1bd12a6c5db8cc905318a992 (commit)
       via  2adcde44af5b170b9c602ffbc3d035bd92b4f05f (commit)
       via  d46ebdc7f1aa7d66d576ec3506edae42181c4e30 (commit)
       via  308fddf4affe8b511c1617230048a554bc19f996 (commit)
       via  0e81ce46c3f8d0b2e404303878c4d203e3523aad (commit)
       via  310f6c81aad96a063f798d5940853dfad3409bba (commit)
       via  0da328cc74af2989f811d2970096bd5be5f9776b (commit)
       via  9573ffcfb52ae30c76d5595fbb67005ef50b95fd (commit)
       via  97e018a1a8b9d4da6c99a9eb7be36a7f368615f9 (commit)
      from  3e515256d1ce0c7c09f4f8454f9761f261fb8b71 (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 b3bb4cdff0b10f42624b67ae19c03f1edfcecab0
Merge: 3e51525 0728458
Author: radhika <radhika at curoverse.com>
Date:   Mon Feb 15 12:35:02 2016 -0500

    Merge branch '8183-projects-dropdown' into 8286-fav-projects
    
    Conflicts:
    	apps/workbench/app/controllers/application_controller.rb
    	apps/workbench/app/views/application/_projects_tree_menu.html.erb
    	apps/workbench/test/controllers/projects_controller_test.rb

diff --cc apps/workbench/app/controllers/application_controller.rb
index 61c57ae,9438da3..5094556
--- a/apps/workbench/app/controllers/application_controller.rb
+++ b/apps/workbench/app/controllers/application_controller.rb
@@@ -94,9 -94,7 +94,10 @@@ class ApplicationController < ActionCon
          # Fall back to the default-setting code later.
        end
      end
 +    @starred_projects ||= []
+     @my_wanted_projects_tree ||= []
 +    @my_project_tree ||= []
 +    @shared_project_tree ||= []
      render_error(err_opts)
    end
  
@@@ -869,17 -832,79 +870,90 @@@
      {collections: c, owners: own}
    end
  
 +  helper_method :my_starred_projects
 +  def my_starred_projects user
 +    return if @starred_projects
 +    links = Link.filter([['tail_uuid', '=', user.uuid],
 +                         ['link_class', '=', 'star'],
 +                         ['head_uuid', 'is_a', 'arvados#group']]).select(%w(head_uuid))
 +    uuids =links.collect { |x| x.head_uuid }
 +    starred_projects = Group.filter([['uuid', 'in', uuids]]).order('name')
 +    @starred_projects = starred_projects.results
 +  end
 +
+   # If there are more than 200 projects that are readable by the user,
+   # build the tree using only the top 200+ projects owned by the user,
+   # from the top three levels.
+   # That is: get toplevel projects under home, get subprojects of
+   # these projects, and so on until we hit the limit.
+   def my_wanted_projects user, page_size=100
+     return @my_wanted_projects if @my_wanted_projects
+ 
+     from_top = []
+     uuids = [user.uuid]
+     depth = 0
+     @too_many_projects = false
+     @reached_level_limit = false
+     while from_top.size <= page_size*2
+       current_level = Group.filter([['group_class','=','project'],
+                                     ['owner_uuid', 'in', uuids]])
+                       .order('name').limit(page_size*2)
+       break if current_level.results.size == 0
+       @too_many_projects = true if current_level.items_available > current_level.results.size
+       from_top.concat current_level.results
+       uuids = current_level.results.collect { |x| x.uuid }
+       depth += 1
+       if depth >= 3
+         @reached_level_limit = true
+         break
+       end
+     end
+     @my_wanted_projects = from_top
+   end
+ 
+   helper_method :my_wanted_projects_tree
+   def my_wanted_projects_tree user, page_size=100
+     build_my_wanted_projects_tree user, page_size
+     [@my_wanted_projects_tree, @too_many_projects, @reached_level_limit]
+   end
+ 
+   def build_my_wanted_projects_tree user, page_size=100
+     return @my_wanted_projects_tree if @my_wanted_projects_tree
+ 
+     parent_of = {user.uuid => 'me'}
+     my_wanted_projects(user, page_size).each do |ob|
+       parent_of[ob.uuid] = ob.owner_uuid
+     end
+     children_of = {false => [], 'me' => [user]}
+     my_wanted_projects(user, page_size).each do |ob|
+       if ob.owner_uuid != user.uuid and
+           not parent_of.has_key? ob.owner_uuid
+         parent_of[ob.uuid] = false
+       end
+       children_of[parent_of[ob.uuid]] ||= []
+       children_of[parent_of[ob.uuid]] << ob
+     end
+     buildtree = lambda do |children_of, root_uuid=false|
+       tree = {}
+       children_of[root_uuid].andand.each do |ob|
+         tree[ob] = buildtree.call(children_of, ob.uuid)
+       end
+       tree
+     end
+     sorted_paths = lambda do |tree, depth=0|
+       paths = []
+       tree.keys.sort_by { |ob|
+         ob.is_a?(String) ? ob : ob.friendly_link_name
+       }.each do |ob|
+         paths << {object: ob, depth: depth}
+         paths += sorted_paths.call tree[ob], depth+1
+       end
+       paths
+     end
+     @my_wanted_projects_tree =
+       sorted_paths.call buildtree.call(children_of, 'me')
+   end
+ 
    helper_method :my_project_tree
    def my_project_tree
      build_project_trees
diff --cc apps/workbench/app/views/application/_projects_tree_menu.html.erb
index 221d9a2,69f97e4..6e116dd
--- a/apps/workbench/app/views/application/_projects_tree_menu.html.erb
+++ b/apps/workbench/app/views/application/_projects_tree_menu.html.erb
@@@ -1,15 -1,26 +1,42 @@@
  <li role="presentation" class="dropdown-header">
-   My projects
++  My favorite projects
 +</li>
 +<li>
 +  <%= project_link_to.call({object: current_user, depth: 0}) do %>
 +    <span style="padding-left: 0">Home</span>
 +  <% end %>
 +</li>
 +<% (my_starred_projects current_user).each do |pnode| %>
 +  <li>
 +    <%= project_link_to.call({object: pnode, depth: 0}) do%>
 +      <span style="padding-left: 0em"></span><%= pnode[:name] %>
 +    <% end %>
 +  </li>
 +<% end %>
++
++<li role="presentation" class="dropdown-header">
+   My projects
+ </li>
+ <li>
+   <%= project_link_to.call({object: current_user, depth: 0}) do %>
+     <span style="padding-left: 0">Home</span>
+   <% end %>
+ </li>
+ <% my_tree = my_wanted_projects_tree current_user %>
+ <% my_tree[0].each do |pnode| %>
+   <% next if pnode[:object].class != Group %>
+   <li>
+     <%= project_link_to.call pnode do %>
+       <span style="padding-left: <%= pnode[:depth] %>em"></span><%= pnode[:object].name %>
+     <% end %>
+   </li>
+ <% end %>
+ <% if my_tree[1] or my_tree[0].size > 200 %>
+ <li role="presentation" class="dropdown-header">
+   Some projects have been omitted.
+ </li>
+ <% elsif my_tree[2] %>
+ <li role="presentation" class="dropdown-header">
+   Showing top three levels of your projects.
+ </li>
+ <% end %>
diff --cc apps/workbench/test/controllers/projects_controller_test.rb
index 643aaae,6bdab55..58914a8
--- a/apps/workbench/test/controllers/projects_controller_test.rb
+++ b/apps/workbench/test/controllers/projects_controller_test.rb
@@@ -420,52 -420,31 +420,81 @@@ class ProjectsControllerTest < ActionCo
    end
  
    [
+     ["active", 5, ["aproject", "asubproject"], "anonymously_accessible_project"],
+     ["user1_with_load", 2, ["project_with_10_collections"], "project_with_2_pipelines_and_60_jobs"],
+     ["admin", 5, ["anonymously_accessible_project", "subproject_in_anonymous_accessible_project"], "aproject"],
+   ].each do |user, page_size, tree_segment, unexpected|
+     test "build my projects tree for #{user} user and verify #{unexpected} is omitted" do
+       use_token user
+       ctrl = ProjectsController.new
+ 
+       current_user = User.find(api_fixture('users')[user]['uuid'])
+ 
+       my_tree = ctrl.send :my_wanted_projects_tree, current_user, page_size
+ 
+       tree_segment_at_depth_1 = api_fixture('groups')[tree_segment[0]]
+       tree_segment_at_depth_2 = api_fixture('groups')[tree_segment[1]] if tree_segment[1]
+ 
+       tree_nodes = {}
+       my_tree[0].each do |x|
+         tree_nodes[x[:object]['uuid']] = x[:depth]
+       end
+ 
+       assert_equal(1, tree_nodes[tree_segment_at_depth_1['uuid']])
+       assert_equal(2, tree_nodes[tree_segment_at_depth_2['uuid']]) if tree_segment[1]
+ 
+       unexpected_project = api_fixture('groups')[unexpected]
+       assert_nil(tree_nodes[unexpected_project['uuid']])
+     end
+   end
++
++  [
 +    ["active", 1],
 +    ["project_viewer", 1],
 +    ["admin", 0],
 +  ].each do |user, size|
 +    test "starred projects for #{user}" do
 +      use_token user
 +      ctrl = ProjectsController.new
 +      current_user = User.find(api_fixture('users')[user]['uuid'])
 +      my_starred_project = ctrl.send :my_starred_projects, current_user
 +      assert_equal(size, my_starred_project.andand.size)
 +
 +      ctrl2 = ProjectsController.new
 +      current_user = User.find(api_fixture('users')[user]['uuid'])
 +      my_starred_project = ctrl2.send :my_starred_projects, current_user
 +      assert_equal(size, my_starred_project.andand.size)
 +    end
 +  end
 +
 +  test "unshare project and verify that it is no longer included in shared user's starred projects" do
 +    # remove sharing link
 +    use_token :system_user
 +    Link.find(api_fixture('links')['share_starred_project_with_project_viewer']['uuid']).destroy
 +
 +    # verify that project is no longer included in starred projects
 +    use_token :project_viewer
 +    current_user = User.find(api_fixture('users')['project_viewer']['uuid'])
 +    ctrl = ProjectsController.new
 +    my_starred_project = ctrl.send :my_starred_projects, current_user
 +    assert_equal(0, my_starred_project.andand.size)
 +
 +    # share it again
 +    @controller = LinksController.new
 +    post :create, {
 +      link: {
 +        link_class: 'permission',
 +        name: 'can_read',
 +        head_uuid: api_fixture('groups')['starred_and_shared_active_user_project']['uuid'],
 +        tail_uuid: api_fixture('users')['project_viewer']['uuid'],
 +      },
 +      format: :json
 +    }, session_for(:system_user)
 +
 +    # verify that the project is again included in starred projects
 +    use_token :project_viewer
 +    ctrl = ProjectsController.new
 +    my_starred_project = ctrl.send :my_starred_projects, current_user
 +    assert_equal(1, my_starred_project.andand.size)
 +  end
  end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list