Class: Decidim::Surveys::Metrics::SurveyParticipantsMetricMeasure
- Inherits:
-
MetricMeasure
- Object
- MetricMeasure
- Decidim::Surveys::Metrics::SurveyParticipantsMetricMeasure
- Defined in:
- decidim-surveys/app/queries/decidim/surveys/metrics/survey_participants_metric_measure.rb
Overview
Searches for Participants in the following actions
- Answer a survey (Surveys)
Instance Method Summary collapse
Methods inherited from MetricMeasure
Constructor Details
This class inherits a constructor from Decidim::MetricMeasure
Instance Method Details
#calculate ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'decidim-surveys/app/queries/decidim/surveys/metrics/survey_participants_metric_measure.rb', line 13 def calculate surveys = Decidim::Surveys::Survey.joins(:component, :questionnaire).where(component: @resource) questionnaires = Decidim::Forms::Questionnaire.includes(:questionnaire_for) .where(questionnaire_for_type: Decidim::Surveys::Survey.name, questionnaire_for_id: surveys.pluck(:id)) answers = Decidim::Forms::Answer.joins(:questionnaire) .where(questionnaire: questionnaires) .where("decidim_forms_answers.created_at <= ?", end_time) { cumulative_users: answers.pluck(:decidim_user_id).uniq, quantity_users: answers.where("decidim_forms_answers.created_at >= ?", start_time).pluck(:decidim_user_id).uniq } end |