2017-12-18 03:36:56 +00:00
|
|
|
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
module Chat::Session::SearchIndex
|
2018-04-26 08:55:53 +00:00
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
# methods defined here are going to extend the class, not the instance of it
|
|
|
|
class_methods do
|
2017-12-18 03:36:56 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
lookup name of ref. objects
|
|
|
|
|
|
|
|
chat_session = Chat::Session.find(123)
|
|
|
|
result = chat_session.search_index_attribute_lookup
|
|
|
|
|
|
|
|
returns
|
|
|
|
|
|
|
|
attributes # object with lookup data
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
def search_index_attribute_lookup
|
|
|
|
attributes = super
|
|
|
|
return if !attributes
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
attributes[:tag] = tag_list
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
messages = Chat::Message.where(chat_session_id: id)
|
|
|
|
attributes['messages'] = []
|
|
|
|
messages.each do |message|
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
# lookup attributes of ref. objects (normally name and note)
|
|
|
|
message_attributes = message.search_index_attribute_lookup
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
attributes['messages'].push message_attributes
|
|
|
|
end
|
2017-12-18 03:36:56 +00:00
|
|
|
|
2018-04-26 08:55:53 +00:00
|
|
|
attributes
|
|
|
|
end
|
2017-12-18 03:36:56 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|