docbrown/app/serializers/search/postgres_user_serializer.rb
rhymes 996f6e980f
[Search 2.0] Users (#13453)
* Add Search::Postgres::User

* Add sorting params

* Use a better algorithm to filter out suspended users

* Add tsvector index on users.name

* Add specs

* Add UserRole spec

* Update spec/services/search/postgres/user_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Fix search with quotes in users's names

Co-authored-by: Michael Kohl <citizen428@dev.to>
2021-04-24 19:06:06 +02:00

17 lines
467 B
Ruby

module Search
# to be renamed when ES is gone
class PostgresUserSerializer < ApplicationSerializer
attribute :class_name, -> { "User" }
attributes :id, :path
attribute :title, &:name
attribute :user do |user|
{
# currently the frontend expects this to be the username, despite the attribute name
name: user.username,
profile_image_90: user.profile_image_90,
username: user.username
}
end
end
end