Streamline of index attributes.
This commit is contained in:
parent
a6826a9166
commit
632d879e2c
4 changed files with 5 additions and 52 deletions
|
@ -18,11 +18,7 @@ returns
|
|||
return if !self.class.search_index_support_config
|
||||
|
||||
# default ignored attributes
|
||||
ignore_attributes = {
|
||||
created_by_id: true,
|
||||
updated_by_id: true,
|
||||
active: true,
|
||||
}
|
||||
ignore_attributes = {}
|
||||
if self.class.search_index_support_config[:ignore_attributes]
|
||||
self.class.search_index_support_config[:ignore_attributes].each {|key, value|
|
||||
ignore_attributes[key] = value
|
||||
|
@ -45,15 +41,7 @@ returns
|
|||
return if !attributes
|
||||
|
||||
# update backend
|
||||
if self.class.column_names.include? 'active'
|
||||
if active
|
||||
SearchIndexBackend.add(self.class.to_s, attributes)
|
||||
else
|
||||
SearchIndexBackend.remove( self.class.to_s, id )
|
||||
end
|
||||
else
|
||||
SearchIndexBackend.add( self.class.to_s, attributes )
|
||||
end
|
||||
end
|
||||
|
||||
=begin
|
||||
|
|
|
@ -18,11 +18,7 @@ returns
|
|||
return if !self.class.search_index_support_config
|
||||
|
||||
# default ignored attributes
|
||||
ignore_attributes = {
|
||||
created_by_id: true,
|
||||
updated_by_id: true,
|
||||
active: true,
|
||||
}
|
||||
ignore_attributes = {}
|
||||
if self.class.search_index_support_config[:ignore_attributes]
|
||||
self.class.search_index_support_config[:ignore_attributes].each {|key, value|
|
||||
ignore_attributes[key] = value
|
||||
|
@ -62,7 +58,7 @@ returns
|
|||
article_attributes = article.attributes
|
||||
|
||||
# remove note needed attributes
|
||||
ignore = %w(created_by_id updated_by_id updated_at references message_id_md5 message_id in_reply_to ticket_id)
|
||||
ignore = %w(message_id_md5)
|
||||
ignore.each {|attribute|
|
||||
article_attributes.delete( attribute )
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ class User < ApplicationModel
|
|||
load 'user/assets.rb'
|
||||
include User::Assets
|
||||
extend User::Search
|
||||
include User::SearchIndex
|
||||
|
||||
before_create :check_name, :check_email, :check_login, :check_password
|
||||
before_update :check_password, :check_email, :check_login
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
class User
|
||||
module SearchIndex
|
||||
|
||||
=begin
|
||||
|
||||
get data to store in search index
|
||||
|
||||
user = User.find(123)
|
||||
result = user.search_index_data
|
||||
|
||||
returns
|
||||
|
||||
result = true # false
|
||||
|
||||
=end
|
||||
|
||||
def search_index_data
|
||||
attributes = { 'fullname' => "#{self['firstname']} #{self['lastname']}" }
|
||||
%w(login firstname lastname phone email address city country note created_at).each { |key|
|
||||
if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
|
||||
attributes[key] = self[key]
|
||||
end
|
||||
}
|
||||
return if attributes.empty?
|
||||
attributes
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue