Class: Decidim::Initiatives::InitiativeStatsPresenter
- Inherits:
-
Rectify::Presenter
- Object
- Rectify::Presenter
- Decidim::Initiatives::InitiativeStatsPresenter
- Defined in:
- app/presenters/decidim/initiatives/initiative_stats_presenter.rb
Overview
A presenter to render statistics in the homepage.
Instance Method Summary collapse
- #assistants_count ⇒ Object
- #comments_count ⇒ Object
- #meetings_count ⇒ Object
- #supports_count ⇒ Object
Instance Method Details
#assistants_count ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/presenters/decidim/initiatives/initiative_stats_presenter.rb', line 31 def assistants_count Rails.cache.fetch( "initiative/#{initiative.id}/assistants_count", expires_in: Decidim::Initiatives.stats_cache_expiration_time ) do result = 0 Decidim::Meetings::Meeting.where(component: meetings_component).each do |meeting| result += meeting.attendees_count || 0 end result end end |
#comments_count ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/presenters/decidim/initiatives/initiative_stats_presenter.rb', line 13 def comments_count Rails.cache.fetch( "initiative/#{initiative.id}/comments_count", expires_in: Decidim::Initiatives.stats_cache_expiration_time ) do Decidim::Comments::Comment.where(root_commentable: initiative).count end end |
#meetings_count ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'app/presenters/decidim/initiatives/initiative_stats_presenter.rb', line 22 def meetings_count Rails.cache.fetch( "initiative/#{initiative.id}/meetings_count", expires_in: Decidim::Initiatives.stats_cache_expiration_time ) do Decidim::Meetings::Meeting.where(component: meetings_component).count end end |
#supports_count ⇒ Object
9 10 11 |
# File 'app/presenters/decidim/initiatives/initiative_stats_presenter.rb', line 9 def supports_count initiative.initiative_supports_count end |