Code cleanup.
This commit is contained in:
parent
b7597123fd
commit
6c3dc608ab
3 changed files with 15 additions and 15 deletions
|
@ -36,11 +36,11 @@ create/update/delete index
|
||||||
|
|
||||||
def self.index(data)
|
def self.index(data)
|
||||||
|
|
||||||
url = build_url( data[:name] )
|
url = build_url(data[:name])
|
||||||
return if !url
|
return if !url
|
||||||
|
|
||||||
if data[:action] && data[:action] == 'delete'
|
if data[:action] && data[:action] == 'delete'
|
||||||
return SearchIndexBackend.remove( data[:name] )
|
return SearchIndexBackend.remove(data[:name])
|
||||||
end
|
end
|
||||||
|
|
||||||
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
Rails.logger.info "# curl -X PUT \"#{url}\" \\"
|
||||||
|
@ -66,13 +66,13 @@ create/update/delete index
|
||||||
|
|
||||||
add new object to search index
|
add new object to search index
|
||||||
|
|
||||||
SearchIndexBackend.add( 'Ticket', some_data_object )
|
SearchIndexBackend.add('Ticket', some_data_object)
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.add(type, data)
|
def self.add(type, data)
|
||||||
|
|
||||||
url = build_url( type, data['id'] )
|
url = build_url(type, data['id'])
|
||||||
return if !url
|
return if !url
|
||||||
|
|
||||||
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
Rails.logger.info "# curl -X POST \"#{url}\" \\"
|
||||||
|
@ -98,14 +98,14 @@ add new object to search index
|
||||||
|
|
||||||
remove whole data from index
|
remove whole data from index
|
||||||
|
|
||||||
SearchIndexBackend.remove( 'Ticket', 123 )
|
SearchIndexBackend.remove('Ticket', 123)
|
||||||
|
|
||||||
SearchIndexBackend.remove( 'Ticket' )
|
SearchIndexBackend.remove('Ticket')
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.remove( type, o_id = nil )
|
def self.remove(type, o_id = nil)
|
||||||
url = build_url( type, o_id )
|
url = build_url(type, o_id)
|
||||||
return if !url
|
return if !url
|
||||||
|
|
||||||
Rails.logger.info "# curl -X DELETE \"#{url}\""
|
Rails.logger.info "# curl -X DELETE \"#{url}\""
|
||||||
|
@ -129,9 +129,9 @@ remove whole data from index
|
||||||
|
|
||||||
return search result
|
return search result
|
||||||
|
|
||||||
result = SearchIndexBackend.search( 'search query', limit, ['User', 'Organization'] )
|
result = SearchIndexBackend.search('search query', limit, ['User', 'Organization'])
|
||||||
|
|
||||||
result = SearchIndexBackend.search( 'search query', limit, 'User' )
|
result = SearchIndexBackend.search('search query', limit, 'User')
|
||||||
|
|
||||||
result = [
|
result = [
|
||||||
{
|
{
|
||||||
|
@ -150,7 +150,7 @@ return search result
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.search( query, limit = 10, index = nil, query_extention = {} )
|
def self.search(query, limit = 10, index = nil, query_extention = {})
|
||||||
return [] if !query
|
return [] if !query
|
||||||
|
|
||||||
url = build_url()
|
url = build_url()
|
||||||
|
@ -445,7 +445,7 @@ return true if backend is configured
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.build_url( type = nil, o_id = nil )
|
def self.build_url(type = nil, o_id = nil)
|
||||||
return if !SearchIndexBackend.enabled?
|
return if !SearchIndexBackend.enabled?
|
||||||
index = Setting.get('es_index').to_s + "_#{Rails.env}"
|
index = Setting.get('es_index').to_s + "_#{Rails.env}"
|
||||||
url = Setting.get('es_url')
|
url = Setting.get('es_url')
|
||||||
|
|
4
test/fixtures/seeds.rb
vendored
4
test/fixtures/seeds.rb
vendored
|
@ -5,10 +5,10 @@
|
||||||
channel_id = nil
|
channel_id = nil
|
||||||
channel = Channel.find_by(area: 'Email::Notification', active: true)
|
channel = Channel.find_by(area: 'Email::Notification', active: true)
|
||||||
if channel
|
if channel
|
||||||
channel_id = channel
|
channel_id = channel.id
|
||||||
end
|
end
|
||||||
|
|
||||||
email_address = EmailAddress.create_if_not_exists(
|
email_address = EmailAddress.create_or_update(
|
||||||
realname: 'Zammad',
|
realname: 'Zammad',
|
||||||
email: 'zammad@localhost',
|
email: 'zammad@localhost',
|
||||||
channel_id: channel_id,
|
channel_id: channel_id,
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ReportTest < ActiveSupport::TestCase
|
||||||
# Setting.set('es_index', 'estest.local_zammad')
|
# Setting.set('es_index', 'estest.local_zammad')
|
||||||
# Setting.set('es_user', 'elasticsearch')
|
# Setting.set('es_user', 'elasticsearch')
|
||||||
# Setting.set('es_password', 'zammad')
|
# Setting.set('es_password', 'zammad')
|
||||||
# Setting.set('es_attachment_max_size_in_mb', 1 )
|
# Setting.set('es_attachment_max_size_in_mb', 1)
|
||||||
|
|
||||||
# clear cache
|
# clear cache
|
||||||
Cache.clear
|
Cache.clear
|
||||||
|
|
Loading…
Reference in a new issue