[ARVADOS] created: 6b8e471dcc83ecb867dc4ba7358e9bfd90341049
git at public.curoverse.com
git at public.curoverse.com
Sun Jan 11 14:13:14 EST 2015
at 6b8e471dcc83ecb867dc4ba7358e9bfd90341049 (commit)
commit 6b8e471dcc83ecb867dc4ba7358e9bfd90341049
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 10 02:55:55 2015 -0500
3021: Use Oj to encode/decode API responses.
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index 54d5adb..a771042 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -77,7 +77,9 @@ class ApplicationController < ActionController::Base
end
def show
- render json: @object.as_api_response(nil, select: @select)
+ render(text: Oj.dump(@object.as_api_response(nil, select: @select),
+ mode: :compat).html_safe,
+ content_type: 'application/json')
end
def create
@@ -441,7 +443,8 @@ class ApplicationController < ActionController::Base
except(:limit).except(:offset).
count(:id, distinct: true)
end
- render json: @object_list
+ render(text: Oj.dump(@object_list, mode: :compat).html_safe,
+ content_type: 'application/json')
end
def remote_ip
diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index 216dd2d..5ea6e62 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -25,7 +25,7 @@ require 'rails/test_help'
module ArvadosTestSupport
def json_response
- ActiveSupport::JSON.decode @response.body
+ Oj.load response.body
end
def api_token(api_client_auth_name)
commit e0d047ba6f48708550d7a53644d2affacbfc2e43
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 10 02:54:22 2015 -0500
3021: Do not compute etag for initial model state unless/until actually needed.
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index a3e8ec6..38a46de 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -523,8 +523,8 @@ class ArvadosModel < ActiveRecord::Base
end
def log_start_state
- @old_etag = etag
- @old_attributes = logged_attributes
+ @old_attributes = attributes
+ @old_logged_attributes = logged_attributes
end
def log_change(event_type)
@@ -543,14 +543,14 @@ class ArvadosModel < ActiveRecord::Base
def log_update
log_change('update') do |log|
- log.fill_properties('old', @old_etag, @old_attributes)
+ log.fill_properties('old', etag(@old_attributes), @old_logged_attributes)
log.update_to self
end
end
def log_destroy
log_change('destroy') do |log|
- log.fill_properties('old', @old_etag, @old_attributes)
+ log.fill_properties('old', etag(@old_attributes), @old_logged_attributes)
log.update_to nil
end
end
diff --git a/services/api/lib/kind_and_etag.rb b/services/api/lib/kind_and_etag.rb
index 89c01ef..04fdca4 100644
--- a/services/api/lib/kind_and_etag.rb
+++ b/services/api/lib/kind_and_etag.rb
@@ -14,7 +14,7 @@ module KindAndEtag
self.class.kind
end
- def etag
- Digest::MD5.hexdigest(self.inspect).to_i(16).to_s(36)
+ def etag attrs=nil
+ Digest::MD5.hexdigest((attrs || self.attributes).inspect).to_i(16).to_s(36)
end
end
commit 15ae2d2caa3209003648296385566381cfc0076e
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 10 02:18:00 2015 -0500
3021: Call Rails.application.eager_load! only once, not every single
time we use the uuid prefix cache.
diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb
index a170fb9..a3e8ec6 100644
--- a/services/api/app/models/arvados_model.rb
+++ b/services/api/app/models/arvados_model.rb
@@ -432,6 +432,7 @@ class ArvadosModel < ActiveRecord::Base
def self.uuid_prefixes
unless @@prefixes_hash
@@prefixes_hash = {}
+ Rails.application.eager_load!
ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |k|
if k.respond_to?(:uuid_prefix)
@@prefixes_hash[k.uuid_prefix] = k
@@ -498,7 +499,6 @@ class ArvadosModel < ActiveRecord::Base
end
resource_class = nil
- Rails.application.eager_load!
uuid.match HasUuid::UUID_REGEX do |re|
return uuid_prefixes[re[1]] if uuid_prefixes[re[1]]
end
commit 5ebd32d67d0bcb26ae034e01bc928795bb0fcfe7
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 10 03:49:25 2015 -0500
3021: Add a performance test.
ActiveSupport doesn't seem to think its profiling code is compatible
with Ruby 2.1, but it seems to work if you patch up a version check in
activesupport:
.../activesupport-3.2.17/lib/active_support/testing/performance/ruby.rb
-if RUBY_VERSION.between?('1.9.2', '2.0.0')
+if RUBY_VERSION.between?('1.9.2', '3.0.0')
diff --git a/services/api/Gemfile b/services/api/Gemfile
index a7da122..4cb5b19 100644
--- a/services/api/Gemfile
+++ b/services/api/Gemfile
@@ -8,6 +8,7 @@ gem 'rails', '~> 3.2.0'
group :test, :development do
gem 'factory_girl_rails'
gem 'database_cleaner'
+ gem 'ruby-prof'
# Note: "require: false" here tells bunder not to automatically
# 'require' the packages during application startup. Installation is
# still mandatory.
diff --git a/services/api/Gemfile.lock b/services/api/Gemfile.lock
index c2b2351..5f57d10 100644
--- a/services/api/Gemfile.lock
+++ b/services/api/Gemfile.lock
@@ -174,6 +174,7 @@ GEM
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
+ ruby-prof (0.15.2)
rvm-capistrano (1.5.1)
capistrano (~> 2.15.4)
sass (3.3.4)
@@ -240,6 +241,7 @@ DEPENDENCIES
pg_power
puma
rails (~> 3.2.0)
+ ruby-prof
rvm-capistrano
sass-rails (>= 3.2.0)
simplecov (~> 0.7.1)
diff --git a/services/api/test/performance/browsing_test.rb b/services/api/test/performance/browsing_test.rb
deleted file mode 100644
index 3fea27b..0000000
--- a/services/api/test/performance/browsing_test.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-class BrowsingTest < ActionDispatch::PerformanceTest
- # Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
- # :output => 'tmp/performance', :formats => [:flat] }
-
- def test_homepage
- get '/'
- end
-end
diff --git a/services/api/test/performance/links_index_test.rb b/services/api/test/performance/links_index_test.rb
new file mode 100644
index 0000000..a183a90
--- /dev/null
+++ b/services/api/test/performance/links_index_test.rb
@@ -0,0 +1,14 @@
+require 'test_helper'
+require 'rails/performance_test_help'
+
+class IndexTest < ActionDispatch::PerformanceTest
+ def test_links_index
+ get '/arvados/v1/links', {format: :json}, auth(:admin)
+ end
+ def test_links_index_with_filters
+ get '/arvados/v1/links', {format: :json, filters: [%w[head_uuid is_a arvados#collection]].to_json}, auth(:admin)
+ end
+ def test_collections_index
+ get '/arvados/v1/collections', {format: :json}, auth(:admin)
+ end
+end
commit cedde3e5d83a44a4e312d17d313a8eae96885962
Author: Tom Clegg <tom at curoverse.com>
Date: Sat Jan 10 03:35:28 2015 -0500
Fix crash on missing return_to param.
diff --git a/services/api/lib/josh_id.rb b/services/api/lib/josh_id.rb
index a63b251..a7e8ff2 100644
--- a/services/api/lib/josh_id.rb
+++ b/services/api/lib/josh_id.rb
@@ -42,7 +42,7 @@ module OmniAuth
end
def callback_url
- full_host + script_name + callback_path + "?return_to=" + CGI.escape(request.params['return_to'])
+ full_host + script_name + callback_path + "?return_to=" + CGI.escape(request.params['return_to'] || '')
end
def raw_info
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list