X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4689cec4c94dbbfcf990250e15ae6e822f9fd170..25af6c40181b95f13ec3e9e366c53cb50868d065:/services/api/app/models/arvados_model.rb diff --git a/services/api/app/models/arvados_model.rb b/services/api/app/models/arvados_model.rb index 672374bc6c..b2e1bea3ab 100644 --- a/services/api/app/models/arvados_model.rb +++ b/services/api/app/models/arvados_model.rb @@ -32,7 +32,11 @@ class ArvadosModel < ActiveRecord::Base # Note: This only returns permission links. It does not account for # permissions obtained via user.is_admin or # user.uuid==object.owner_uuid. - has_many :permissions, :foreign_key => :head_uuid, :class_name => 'Link', :primary_key => :uuid, :conditions => "link_class = 'permission'" + has_many(:permissions, + foreign_key: :head_uuid, + class_name: 'Link', + primary_key: :uuid, + conditions: "link_class = 'permission'") class PermissionDeniedError < StandardError def http_status @@ -239,7 +243,7 @@ class ArvadosModel < ActiveRecord::Base end def logged_attributes - attributes.except *Rails.configuration.unlogged_attributes + attributes.except(*Rails.configuration.unlogged_attributes) end def self.full_text_searchable_columns @@ -252,12 +256,7 @@ class ArvadosModel < ActiveRecord::Base parts = full_text_searchable_columns.collect do |column| "coalesce(#{column},'')" end - # We prepend a space to the tsvector() argument here. Otherwise, - # it might start with a column that has its own (non-full-text) - # index, which causes Postgres to use the column index instead of - # the tsvector index, which causes full text queries to be just as - # slow as if we had no index at all. - "to_tsvector('english', ' ' || #{parts.join(" || ' ' || ")})" + "to_tsvector('english', #{parts.join(" || ' ' || ")})" end def self.apply_filters query, filters @@ -490,7 +489,7 @@ class ArvadosModel < ActiveRecord::Base end def foreign_key_attributes - attributes.keys.select { |a| a.match /_uuid$/ } + attributes.keys.select { |a| a.match(/_uuid$/) } end def skip_uuid_read_permission_check @@ -505,7 +504,7 @@ class ArvadosModel < ActiveRecord::Base foreign_key_attributes.each do |attr| attr_value = send attr if attr_value.is_a? String and - attr_value.match /^[0-9a-f]{32,}(\+[@\w]+)*$/ + attr_value.match(/^[0-9a-f]{32,}(\+[@\w]+)*$/) begin send "#{attr}=", Collection.normalize_uuid(attr_value) rescue @@ -584,13 +583,12 @@ class ArvadosModel < ActiveRecord::Base unless uuid.is_a? String return nil end - resource_class = nil uuid.match HasUuid::UUID_REGEX do |re| return uuid_prefixes[re[1]] if uuid_prefixes[re[1]] end - if uuid.match /.+@.+/ + if uuid.match(/.+@.+/) return Email end @@ -603,7 +601,7 @@ class ArvadosModel < ActiveRecord::Base if self == ArvadosModel # If called directly as ArvadosModel.find_by_uuid rather than via subclass, # delegate to the appropriate subclass based on the given uuid. - self.resource_class_for_uuid(uuid).find_by_uuid(uuid) + self.resource_class_for_uuid(uuid).unscoped.find_by_uuid(uuid) else super end @@ -636,7 +634,7 @@ class ArvadosModel < ActiveRecord::Base end def log_destroy - log_change('destroy') do |log| + log_change('delete') do |log| log.fill_properties('old', etag(@old_attributes), @old_logged_attributes) log.update_to nil end