FIX: handle missing user records
This commit is contained in:
parent
ad02437358
commit
06e509057e
|
@ -92,9 +92,10 @@ class TopicViewSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
if object.post_counts_by_user.present?
|
if object.post_counts_by_user.present?
|
||||||
result[:participants] = object.post_counts_by_user.map do |pc|
|
participants = object.post_counts_by_user.reject{ |p| object.participants[p].blank? }.map do |pc|
|
||||||
TopicPostCountSerializer.new({ user: object.participants[pc[0]], post_count: pc[1] }, scope: scope, root: false)
|
TopicPostCountSerializer.new({ user: object.participants[pc[0]], post_count: pc[1] }, scope: scope, root: false)
|
||||||
end
|
end
|
||||||
|
result[:participants] = participants if participants.length > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if object.links.present?
|
if object.links.present?
|
||||||
|
|
Loading…
Reference in New Issue