Push users.preferences to elasticsearch to enable searches for certain features.

This commit is contained in:
Martin Edenhofer 2017-12-14 21:05:59 +01:00
parent e460c99cad
commit 34c14a22b5
3 changed files with 4 additions and 7 deletions

View file

@ -72,8 +72,7 @@ class User < ApplicationModel
:image, :image,
:image_source, :image_source,
:source, :source,
:login_failed, :login_failed
:preferences
def ignore_search_indexing?(_action) def ignore_search_indexing?(_action)
# ignore internal user # ignore internal user

View file

@ -50,11 +50,6 @@ returns
def search_index_data def search_index_data
attributes = {} attributes = {}
self.attributes.each do |key, value| self.attributes.each do |key, value|
next if key == 'created_at'
next if key == 'updated_at'
next if key == 'created_by_id'
next if key == 'updated_by_id'
next if key == 'preferences'
next if key == 'password' next if key == 'password'
next if !value next if !value
next if value.respond_to?('blank?') && value.blank? next if value.respond_to?('blank?') && value.blank?

View file

@ -114,6 +114,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
assert_equal('E', attributes['firstname']) assert_equal('E', attributes['firstname'])
assert_equal('S', attributes['lastname']) assert_equal('S', attributes['lastname'])
assert_equal('es-agent@example.com', attributes['email']) assert_equal('es-agent@example.com', attributes['email'])
assert(attributes['preferences'])
assert_not(attributes['password']) assert_not(attributes['password'])
assert_not(attributes['organization']) assert_not(attributes['organization'])
@ -121,6 +122,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
assert_equal('E', attributes['firstname']) assert_equal('E', attributes['firstname'])
assert_equal('S', attributes['lastname']) assert_equal('S', attributes['lastname'])
assert_equal('es-agent@example.com', attributes['email']) assert_equal('es-agent@example.com', attributes['email'])
assert(attributes['preferences'])
assert_not(attributes['password']) assert_not(attributes['password'])
assert_not(attributes['organization']) assert_not(attributes['organization'])
@ -128,6 +130,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
assert_equal('ES', attributes['firstname']) assert_equal('ES', attributes['firstname'])
assert_equal('Customer1', attributes['lastname']) assert_equal('Customer1', attributes['lastname'])
assert_equal('es-customer1@example.com', attributes['email']) assert_equal('es-customer1@example.com', attributes['email'])
assert(attributes['preferences'])
assert_not(attributes['password']) assert_not(attributes['password'])
assert_equal('Customer Organization Update', attributes['organization']) assert_equal('Customer Organization Update', attributes['organization'])