Class: Decidim::ActionDelegator::Elections::Admin::ResultsController
- Inherits:
-
Admin::ApplicationController
- Object
- Decidim::Admin::ApplicationController
- Admin::ApplicationController
- Decidim::ActionDelegator::Elections::Admin::ResultsController
- Includes:
- SettingsHelper
- Defined in:
- app/controllers/decidim/action_delegator/elections/admin/results_controller.rb
Instance Method Summary collapse
-
#by_type_and_weight ⇒ Object
TODO: authentication.
- #sum_of_weights ⇒ Object
- #totals ⇒ Object
Methods included from SettingsHelper
#current_resource_settings, #delegations_for, #elections_question_responses_by_type, #elections_question_stats, #elections_question_weighted_responses, #participant_voted?, #settings_for
Methods inherited from Admin::ApplicationController
#current_setting, #organization_settings, #permission_class_chain
Instance Method Details
#by_type_and_weight ⇒ Object
TODO: authentication
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/decidim/action_delegator/elections/admin/results_controller.rb', line 11 def by_type_and_weight render json: { id: election.id, ongoing: election.ongoing?, questions: election.questions.map do |question| { id: question.id, response_options: elections_question_responses_by_type(question) } end } end |
#sum_of_weights ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/decidim/action_delegator/elections/admin/results_controller.rb', line 24 def sum_of_weights render json: { id: election.id, ongoing: election.ongoing?, questions: election.questions.map do |question| { id: question.id, response_options: elections_question_weighted_responses(question) } end } end |
#totals ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/decidim/action_delegator/elections/admin/results_controller.rb', line 37 def totals render json: { id: election.id, ongoing: election.ongoing?, questions: election.questions.map do |question| { id: question.id }.merge( elections_question_stats(question) ) end } end |