Community counter now shows the community members. For performance
reasons this information is refresed once per hour.
This commit is contained in:
Juan Salvador Pérez García
2018-06-29 12:56:20 +02:00
parent 0e71de2bba
commit 53baf983b5
2 changed files with 9 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
class Dashboard::BaseController < ApplicationController
before_action :authenticate_user!
helper_method :proposal, :proposed_actions, :resource, :resources, :next_goal_supports, :next_goal_progress
helper_method :proposal, :proposed_actions, :resource, :resources, :next_goal_supports, :next_goal_progress, :community_members_count
respond_to :html
layout 'proposals_dashboard'
@@ -9,7 +9,7 @@ class Dashboard::BaseController < ApplicationController
private
def proposal
@proposal ||= Proposal.find(params[:proposal_id])
@proposal ||= Proposal.includes(:community).find(params[:proposal_id])
end
def proposed_actions
@@ -27,4 +27,10 @@ class Dashboard::BaseController < ApplicationController
def next_goal_progress
@next_goal_progress ||= (proposal.votes_for.size * 100) / next_goal_supports.to_i
end
def community_members_count
Rails.cache.fetch("community/#{proposal.community.id}/participants_count", expires_in: 1.hour) do
proposal.community.participants.count
end
end
end