search_index.rb 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. module Chat::Session::SearchIndex
  3. extend ActiveSupport::Concern
  4. # methods defined here are going to extend the class, not the instance of it
  5. class_methods do
  6. =begin
  7. lookup name of ref. objects
  8. chat_session = Chat::Session.find(123)
  9. result = chat_session.search_index_attribute_lookup
  10. returns
  11. attributes # object with lookup data
  12. =end
  13. def search_index_attribute_lookup
  14. attributes = super
  15. return if !attributes
  16. attributes[:tags] = tag_list
  17. messages = Chat::Message.where(chat_session_id: id)
  18. attributes['messages'] = []
  19. messages.each do |message|
  20. # lookup attributes of ref. objects (normally name and note)
  21. message_attributes = message.search_index_attribute_lookup
  22. attributes['messages'].push message_attributes
  23. end
  24. attributes
  25. end
  26. end
  27. end