BUGFIX: missing avatars in search
This commit is contained in:
parent
ab20d0aa10
commit
c5a3bfdfa9
|
@ -11,7 +11,7 @@ class Search
|
||||||
attr_accessor :color, :text_color
|
attr_accessor :color, :text_color
|
||||||
|
|
||||||
# User attributes
|
# User attributes
|
||||||
attr_accessor :avatar_template
|
attr_accessor :avatar_template, :uploaded_avatar_id
|
||||||
|
|
||||||
def initialize(row)
|
def initialize(row)
|
||||||
row.symbolize_keys!
|
row.symbolize_keys!
|
||||||
|
@ -21,10 +21,15 @@ class Search
|
||||||
|
|
||||||
def as_json(options = nil)
|
def as_json(options = nil)
|
||||||
json = {id: @id, title: @title, url: @url}
|
json = {id: @id, title: @title, url: @url}
|
||||||
json[:avatar_template] = @avatar_template if @avatar_template.present?
|
[ :avatar_template,
|
||||||
json[:color] = @color if @color.present?
|
:uploaded_avatar_id,
|
||||||
json[:text_color] = @text_color if @text_color.present?
|
:color,
|
||||||
json[:blurb] = @blurb if @blurb.present?
|
:text_color,
|
||||||
|
:blurb
|
||||||
|
].each do |k|
|
||||||
|
val = send(k)
|
||||||
|
json[k] = val if val
|
||||||
|
end
|
||||||
json
|
json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -36,8 +41,13 @@ class Search
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_user(u)
|
def self.from_user(u)
|
||||||
SearchResult.new(type: :user, id: u.username_lower, title: u.username, url: "/users/#{u.username_lower}").tap do |r|
|
SearchResult.new(
|
||||||
r.avatar_template = u.avatar_template
|
type: :user,
|
||||||
|
id: u.username_lower,
|
||||||
|
title: u.username,
|
||||||
|
url: "/users/#{u.username_lower}").tap do |r|
|
||||||
|
r.uploaded_avatar_id = u.uploaded_avatar_id
|
||||||
|
r.avatar_template = u.avatar_template
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue