From 88ecd877596e9e56025e5b54579e1a71702d2d29 Mon Sep 17 00:00:00 2001 From: Marcela Ribeiro de Oliveira <mro15@inf.ufpr.br> Date: Thu, 1 Jun 2017 11:38:41 -0300 Subject: [PATCH] change learning_objects_count to return only the published objects --- app/serializers/user_serializer.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index e59d0145..8a840883 100644 --- a/app/serializers/user_serializer.rb +++ b/app/serializers/user_serializer.rb @@ -13,6 +13,10 @@ class UserSerializer < ActiveModel::Serializer object.email if (current_user != nil)&&(object.id == current_user.id || current_user.is_admin?) end + def learning_objects_count + object.learning_objects.where('state = ?', LearningObject.states[:published]).count + end + attributes :id, :email, :provider, :name, :description, :education, :score, :cover, :role_ids, :institution_ids, :avatar, :likes_count, :followed, :complained, :follows_count, :learning_objects_count, :collections_count, :created_at, :updated_at has_many :subjects end -- GitLab