Class: Decidim::Consultations::QuestionStatsPresenter
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Decidim::Consultations::QuestionStatsPresenter
- Defined in:
- app/presenters/decidim/consultations/question_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
- #question ⇒ Object
- #supports_count ⇒ Object
Instance Method Details
#assistants_count ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/presenters/decidim/consultations/question_stats_presenter.rb', line 33 def assistants_count Rails.cache.fetch( "question/#{question.id}/assistants_count", expires_in: Decidim::Consultations.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
15 16 17 18 19 20 21 22 |
# File 'app/presenters/decidim/consultations/question_stats_presenter.rb', line 15 def comments_count Rails.cache.fetch( "question/#{question.id}/comments_count", expires_in: Decidim::Consultations.stats_cache_expiration_time ) do question.comments_count end end |
#meetings_count ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'app/presenters/decidim/consultations/question_stats_presenter.rb', line 24 def meetings_count Rails.cache.fetch( "question/#{question.id}/meetings_count", expires_in: Decidim::Consultations.stats_cache_expiration_time ) do Decidim::Meetings::Meeting.where(component: meetings_component).count end end |
#question ⇒ Object
7 8 9 |
# File 'app/presenters/decidim/consultations/question_stats_presenter.rb', line 7 def question __getobj__.fetch(:question) end |
#supports_count ⇒ Object
11 12 13 |
# File 'app/presenters/decidim/consultations/question_stats_presenter.rb', line 11 def supports_count question.votes_count end |