[ARVADOS] updated: 1d5a33d2af1e39041177681c8d66007b40b20df4

git at public.curoverse.com git at public.curoverse.com
Fri May 2 16:10:13 EDT 2014


Summary of changes:
 apps/workbench/app/controllers/users_controller.rb |    8 +++---
 doc/api/methods.html.textile.liquid                |    2 +-
 services/api/lib/load_param.rb                     |   10 ++++++--
 services/api/test/integration/select_test.rb       |   22 ++++++++++++++++++++
 4 files changed, 34 insertions(+), 8 deletions(-)

       via  1d5a33d2af1e39041177681c8d66007b40b20df4 (commit)
      from  dca6cfe9750d8d1be4f3b63895b8cb73cc6c4cfe (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 1d5a33d2af1e39041177681c8d66007b40b20df4
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Fri May 2 16:10:10 2014 -0400

    Restored support for old-style 'order' strings and added test.  Clarified
    documentation for 'distinct' as to the default behavior.

diff --git a/apps/workbench/app/controllers/users_controller.rb b/apps/workbench/app/controllers/users_controller.rb
index 5cfa487..8638761 100644
--- a/apps/workbench/app/controllers/users_controller.rb
+++ b/apps/workbench/app/controllers/users_controller.rb
@@ -74,7 +74,7 @@ class UsersController < ApplicationController
       storage_log = Log.
         filter([[:object_uuid, '=', u.uuid],
                 [:event_type, '=', 'user-storage-report']]).
-        order(['created_at desc']).
+        order(:created_at => :desc).
         limit(1)
       storage_log.each do |log_entry|
         # We expect this block to only execute once since we specified limit(1)
@@ -122,12 +122,12 @@ class UsersController < ApplicationController
 
     @my_jobs = Job.
       limit(10).
-      order(['created_at desc']).
+      order('created_at desc').
       where(created_by: current_user.uuid)
 
     @my_collections = Collection.
       limit(10).
-      order(['created_at desc']).
+      order('created_at desc').
       where(created_by: current_user.uuid)
     collection_uuids = @my_collections.collect &:uuid
 
@@ -151,7 +151,7 @@ class UsersController < ApplicationController
 
     @my_pipelines = PipelineInstance.
       limit(10).
-      order(['created_at desc']).
+      order('created_at desc').
       where(created_by: current_user.uuid)
 
     respond_to do |f|
diff --git a/doc/api/methods.html.textile.liquid b/doc/api/methods.html.textile.liquid
index 3d93e88..57d058e 100644
--- a/doc/api/methods.html.textile.liquid
+++ b/doc/api/methods.html.textile.liquid
@@ -29,7 +29,7 @@ table(table table-bordered table-condensed).
 |filters |array  |Conditions for selecting resources to return|
 |order   |array  |List of fields to use to determine sorting order for returned objects|
 |select  |array  |Specify which fields to return|
-|distinct|boolean|true: do not return duplicate objects, default; false: permitted to return duplicates|
+|distinct|boolean|true: (default) do not return duplicate objects<br> false: permitted to return duplicates|
 
 h2. Create
 
diff --git a/services/api/lib/load_param.rb b/services/api/lib/load_param.rb
index 11f18f7..7acf014 100644
--- a/services/api/lib/load_param.rb
+++ b/services/api/lib/load_param.rb
@@ -72,9 +72,13 @@ module LoadParam
       od = []
       (case params[:order]
        when String
-         od = Oj.load(params[:order])
-         raise unless od.is_a? Array
-         od
+         if params[:order].starts_with? '['
+           od = Oj.load(params[:order])
+           raise unless od.is_a? Array
+           od
+         else
+           params[:order].split(',')
+         end
        when Array
          params[:order]
        else
diff --git a/services/api/test/integration/select_test.rb b/services/api/test/integration/select_test.rb
index cf4d951..b5f09df 100644
--- a/services/api/test/integration/select_test.rb
+++ b/services/api/test/integration/select_test.rb
@@ -57,4 +57,26 @@ class SelectTest < ActionDispatch::IntegrationTest
     end
   end
 
+  test "select two columns with old-style order syntax" do
+    get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => 'link_class asc, uuid desc'}, auth(:active)
+    assert_response :success
+
+    assert json_response['items'].length > 0
+
+    prev_link_class = ""
+    prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
+
+    json_response['items'].each do |i|
+      if prev_link_class != i['link_class']
+        prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz"
+      end
+
+      assert i['link_class'] >= prev_link_class
+      assert i['uuid'] < prev_uuid
+
+      prev_link_class = i['link_class']
+      prev_uuid = i['uuid']
+    end
+  end
+
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list