From 06e509057ee74310c1b033498d9e05169e781bfd Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 3 Jan 2018 17:05:01 +0530 Subject: [PATCH] FIX: handle missing user records --- app/serializers/topic_view_serializer.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/serializers/topic_view_serializer.rb b/app/serializers/topic_view_serializer.rb index 9297793726d..1d1577d6d35 100644 --- a/app/serializers/topic_view_serializer.rb +++ b/app/serializers/topic_view_serializer.rb @@ -92,9 +92,10 @@ class TopicViewSerializer < ApplicationSerializer end 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) end + result[:participants] = participants if participants.length > 0 end if object.links.present?