Sha256: 7e46daee2e21ff6c38718bc584cacdc61be0b7d444e55e51f1e57570accf4f17
Contents?: true
Size: 1.5 KB
Versions: 26
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module Decidim module Sortitions module Admin class ParticipatorySpaceProposals < Rectify::Query # Sugar syntax. Retrieve all proposals for the given sortition. def self.for(sortition) new(sortition).query end # Initializes the class. # # sortition - a sortition to select proposals def initialize(sortition) @sortition = sortition @category = sortition.category @request_timestamp = sortition.request_timestamp end # Given a particpiatory process retrieves its proposals # # Returns an ActiveRecord::Relation. def query if category.nil? return Decidim::Proposals::Proposal .except_withdrawn .where("created_at < ?", request_timestamp) .where(component: sortition.decidim_proposals_component) .order(id: :asc) end # categorization -> category Decidim::Proposals::Proposal .joins(:categorization) .except_withdrawn .where(component: sortition.decidim_proposals_component) .where("decidim_proposals_proposals.created_at < ?", request_timestamp) .where("decidim_categorizations.decidim_category_id = ?", category.id) .order(id: :asc) end private attr_reader :sortition, :category, :request_timestamp end end end end
Version data entries
26 entries across 26 versions & 1 rubygems