diff --git a/app/serializers/user_serializer.rb b/app/serializers/user_serializer.rb index e59d014590f1f264f09350ce570b1d3b86f2da7c..8a840883fb6e311d21280abf4e0a81735a26cd22 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