Sha256: 8c39ea743a1334cc975c97154db768d076cad027cf4481cfc9fc8b95daa684d9

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module ActionDelegator
    # Returns all PaperTrail versions of a consultation's delegated votes for auditing purposes.
    # It is intended to be used to easily fetch this data when a judge ask us so.
    class DelegatedVotesVersions
      def initialize(consultation)
        @consultation = consultation
      end

      def query
        PaperTrail::Version
          .joins("INNER JOIN decidim_action_delegator_delegations ON decidim_action_delegator_delegations.id = versions.decidim_action_delegator_delegation_id")
          .joins("INNER JOIN decidim_action_delegator_settings ON decidim_action_delegator_settings.id = decidim_action_delegator_delegations.decidim_action_delegator_setting_id")
          .where(decidim_action_delegator_settings: { decidim_consultation_id: consultation.id })
          .order("versions.created_at ASC")
      end

      private

      attr_reader :consultation
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-action_delegator-0.8.1 app/queries/decidim/action_delegator/delegated_votes_versions.rb
decidim-action_delegator-0.7.2 app/queries/decidim/action_delegator/delegated_votes_versions.rb
decidim-action_delegator-0.7.1 app/queries/decidim/action_delegator/delegated_votes_versions.rb
decidim-action_delegator-0.7.0 app/queries/decidim/action_delegator/delegated_votes_versions.rb