Implements #169
Community counter now shows the community members. For performance reasons this information is refresed once per hour.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</div>
|
||||
|
||||
<div class="counter">
|
||||
<div class="counter-value">0</div>
|
||||
<div class="counter-value"><%= community_members_count %></div>
|
||||
<div class="counter-label"><%= t('.community') %></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user