Deal gracefully with hidden followable in my activity

We were seeing an exception when a user was following a proposal and
that proposal becomes hidden

With this commit we are skipping this proposals and hopefully fixing
this exception

We are also adjusting the count of followed proposals, without
including hidden proposals. It might be cleaner, to remove a `Follow`
when its `Followable` becomes hidden. But then we should probably
activate the `Follow` again if the `Followable` becomes non-hidden…

For now this commit should suffice 😌
This commit is contained in:
rgarcia
2018-05-10 16:07:53 +02:00
committed by decabeza
parent f7f1f12b82
commit 88cde6d018
3 changed files with 18 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ class UsersController < ApplicationController
debates: (Setting['feature.debates'] ? Debate.where(author_id: @user.id).count : 0),
budget_investments: (Setting['feature.budgets'] ? Budget::Investment.where(author_id: @user.id).count : 0),
comments: only_active_commentables.count,
follows: @user.follows.count)
follows: @user.follows.map(&:followable).compact.count)
end
def load_filtered_activity